Re: New to CURL - HTTP POST to web service and response
Date: Thu, 18 Jun 2015 14:55:11 -0400
On 6/18/2015 11:20 AM, Fitzgerald, Kevin wrote:
> Hi, sorry I was not detailed enough. Yes, I am using the POST example
> from the CURL repository. I originally was trying the sendrecv
> example. I replaced the send portion with the POST portion and was
> still using the receive part.
It looks like you mixed two disparate examples together.
CURLOPT_CONNECT_ONLY  will stop the library from initiating a
transfer. So if you use that option then after the connection is
established nothing will happen and you'll have to use curl_easy_send
 and curl_easy_recv . That is what you would do if you needed to
implement a custom protocol.
Instead you should be able to use CURLOPT_POST  and the simplest way
is CURLOPT_POSTFIELDS  as shown in the http-post.c example . As
Tim suggested a write callback  may be helpful if you need to parse
the response because you can use it to direct the response body
somewhere (eg to memory ) instead of having it output to stdout.
However in Tim's code he's also using CURLOPT_CONNECT_ONLY, which you
wouldn't use in this case.
I caution you for security reasons it is not a good idea to disable peer
verification (CURLOPT_SSL_VERIFYPEER) as is shown in your code. If you
can't verify the server successfully find out why. I can here. You may
just need a later certificate bundle . You can change the bundle
location using CURLOPT_CAINFO .
List admin: http://cool.haxx.se/list/listinfo/curl-library
Received on 2015-06-18