cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl fails where netscape succeeds

From: Michael Wood <esiotrot_at_gmail.com>
Date: Mon, 19 Sep 2011 13:42:08 +0200

On 19 September 2011 11:33, John P. Hartmann <jphartmann_at_gmail.com> wrote:
> Absolute beginner.  I must be missing something obvious.
>
> Typing 'http://api.discogs.com/artist/John+Coltrane' into netscape
> gets me information on the saxofonist.

Here you're using "api.discogs.com".

> Sending the same URL with libcurl does not.  The first line is my log
> of the parameter to curl_easy_setopt(curl, CURLOPT_URL, qry);:
>
> Query 'http://www.discogs.com/artist/John+Coltrane'

Here you're using "www.discogs.com".

> * About to connect() to www.discogs.com port 80 (#0)
> *   Trying 70.103.226.22... * connected
>> GET /artist/John+Coltrane HTTP/1.1
> Host: www.discogs.com

One other thing you might want to do is include a User-Agent header.
Some web sites don't like it if you leave that out.

> 500 Client Refused
> * Connection #0 to host www.discogs.com left intact
> * Closing connection #0
>
> Passing the URL to the curl command gets me a different error response:
>
> u@ubuntu:~$ curl 'http://api.discogs.com/artist/John+Coltrane'
> {"resp": {"status": false, "version": "2.0", "error": "Invalid API
> request"}}u_at_ubuntu:~$

You could also try:

curl 'http://api.discogs.com/artist/John+Coltrane' --libcurl discogs-example.c

which will generate a file called discogs-example.c that should do the
same thing as the "curl" command.

-- 
Michael Wood <esiotrot_at_gmail.com>
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2011-09-19