cURL / Mailing Lists / curl-users / Single Mail

curl-users

RE: Web service server doesn't see posted data

From: Bruce, Henry <henry.bruce_at_intel.com>
Date: Thu, 10 Apr 2008 16:28:51 -0700

>> However, when I tried the same approach with the NOAA weather service
with the
>> commands listed below, the call failed, with the server reporting it
didn't see
>> any parameters
>>
>> --url
http://www.weather.gov/forecasts/xml/sample_products/browser_interface/
>> ndfdXMLclient.php
>> --data lat=45.550980
>> --data lon=-122.917359
>> --data product=time-series
>> --data begin=2008-04-08T15:00:00
>> --data end=2008-04-08T16:00:00
>> --data pop12=pop12
>>
>> However, if I put the entire URI into the URL, it works just fine
>> --url
http://www.weather.gov/forecasts/xml/sample_products/browser_interface/
>>
ndfdXMLclient.php?&lat=45.550980&lon=-122.917359&product=time-series&beg
in=
>> 2008-04-08T13:00:00&end=2008-04-08T14:00:00&pop12=pop12
>
>
> The difference between the first and second commands is that the first
does
> a POST while the second does a GET. Add the -G option to the first one
>and it should work.

Thanks Dan - that worked.

However when I generated the libcurl source, I saw that the --get
command caused the post field data to be added to the URL. This implies
that I cannot use the curl_easy_setopt CURLOPT_POSTFIELDS option to set
the web service query string, but must append it to the url (as per the
working example above). This will work, but it makes the libcurl code
messier. I tried setting the CURLOPT_HTTPGET parameter to 1, but this
failed as before. Is there any way I can use the CURLOPT_POSTFIELDS
option, or I must I create the URI myself and use it as paramter for the
CURLOPT_URL option ?

Henry

 
Received on 2008-04-11