cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: CURLOPT_URL returning FALSE

From: Isaac Sanni-Thomas <isaacsannithomas_at_gmail.com>
Date: Tue, 15 Dec 2009 05:49:43 +0000

On 12/15/2009 04:42 AM, nitin.mittal_at_rsa.com wrote:
>
> sending the mail again as some junk got introduced in the sample code
> below.
>
> Regards.
>
> -----Original Message-----
> From: curl-library-bounces_at_cool.haxx.se
> [mailto:curl-library-bounces_at_cool.haxx.se] On Behalf Of
> nitin.mittal_at_rsa.com
> Sent: Tuesday, December 15, 2009 10:01 AM
> To: curl-library_at_cool.haxx.se
> Subject: CURLOPT_URL returning FALSE
>
>
> Hi,
>
> I am just trying to send some POST data to a windows server.
>
> But, CURLOPT_URL, which is the very first line in my code, which sets
> the URL to the server to which I am sending POST data, returns false.
>
> Please find the code sample below:
>
>
> #include<stdio.h>
> #include<curl/curl.h>
>
> int main(void)
> {
> CURL *curl;
> CURLcode res;
>
> curl = curl_easy_init ();
> if(curl) {
> curl_easy_setopt(curl, CURLOPT_URL ,
> "http://10.31.251.161:5985/wsman"); // this call returns FALSE
> ?????????????
>
> curl_easy_cleanup(curl);
> }
> return 0;
> }
>
> Am I missing something? Please suggest.
I dont see the post fields you want to send??
Your code should look like this

  #include<stdio.h>
  #include<curl/curl.h>

  int main(void)
  {
     CURL *curl;
     CURLcode res;

     curl = curl_easy_init ();
     if(curl) {
curl_easy_setopt(curl, CURLOPT_POSTFIELDS,"user=isaac&pas=3434");
curl_easy_setopt(curl,CURLOPT_URL,"http://10.31.251.161:5985/wsman");
     curl_easy_perform(curl);//send to URL

                  }
     return 0;
  }
NB://set the postfields and send.
Ensure that the web app is set to receive post and not get and confirm
it works correctly.
Check logs for data posted by curl.
All the best.

BR,
Isaac
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-12-15