I just started learning bash and I wanted to implement the last.fm API using the curl command. I tried executing following command:
curl http://ws.audioscrobbler.com/2.0/?method=tag.gettopalbums&tag=disco&api_key=(my API KEY)&format=json
but for some reason it gives me the error code 6 "invalid parameters". If I open the link normally it works just fine.
I tried
curl -v http://ws.audioscrobbler.com/2.0/?method=tag.gettopalbums&tag=disco&api_key=(my API KEY)&format=json
and saw
HTTP/1.1 400 Bad Request
But I don't really know what that means.
As stated by Taylor G. you need to enclose the URL in quotation marks as for example the
&in that URL would be interpreted as a new command.Executing the following
will give me this output:
Also you wrote:
In such cases it might be worth looking at the response body as it may contain more information. Here is the response body for the curl request without quotation marks:
APIs often have these error messages so you don't need to rely only on the HTTP status code.