Curl returns forbidden

Re: Curl returns forbidden

Posted 25 Aug 2017, 6:20:47

but as result have Forbidden

Does it work in the interactive interface?

Re: Curl returns forbidden

Posted 28 Aug 2017, 6:59:45

Yes it works in the interactive interface

Re: Curl returns forbidden

Posted 28 Aug 2017, 7:14:11

Well the problem is the requestBody.toString(). You have to add the params as query string params. E.g.

final HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.set(“x-api-key”, “yourkey”);
final UriComponentsBuilder b = UriComponentsBuilder
.fromHttpUrl(“https://api.setlist.fm/rest/1.0/search/setlists”);
b.queryParam(“artistName”, “Springsteen”);
final String response = restTemplate
.exchange(b.toUriString(), HttpMethod.GET, new HttpEntity<>(headers), String.class).getBody();
System.out.println(response);

However you should have received a 404, not a 403. Just to be sure, where you wrote “key”, you actually used your api key, right?

Re: Curl returns forbidden

Posted 28 Aug 2017, 9:49:49

Yes, I used my api key

Re: Curl returns forbidden

Posted 28 Aug 2017, 9:53:56

Does it work using my suggested code changes?

Re: Curl returns forbidden

Posted 29 Aug 2017, 6:47:16

Yes, now it works. Thank you so much :-D

Re: Curl returns forbidden

Posted 9 Jan 2019, 15:36:33

I just registered today and I keep getting a 403 Forbidden on the interactive interface.

Ive tried using the basic 'GET /1.0/artist/{mbid}' whereby you you can only enter, whether you want the response in XML or JSON from the drop down box and enter the {mbid}. I chose either xml or json and I use 'The beatles' mbid (b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d) given in the example but I get {“message”: “Forbidden”}. I get the same message when I use other mbid for different bands from the website.

My API Key: 2425e09c-78ce-4e5d-b458-b6b34bfaf307

Can you please help?

Re: Curl returns forbidden

Posted 10 Jan 2019, 8:47:31

My API Key

Please never share your API key publicly. We had to disable it now since it could have been abused.

Please get yourself a new one and try again, if it still doesn't work get back in here, we can get the API key from your user name. The API is up and operational, so it really should work.

Re: Curl returns forbidden

Posted 10 Jan 2019, 9:02:44

Oops my bad! Im new to APIs. I re-registered for an API key and got it working on the interactive interface but when I use the same mbid and api key whilst making a request from my local host I get a 403 every time :

fetch(
“https://api.setlist.fm/rest/1.0/artist/b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d”,
{
mode: “no-cors”
headers: {
“x-api-key”: “{my newly registered API KEY}”,
Accept: “application/json”
}
}
);

Any ideas why it would throw up a 403. Is it because of local host? Is there more headers I should add in the request?

Re: Curl returns forbidden

Posted 10 Jan 2019, 9:11:24

curl https://api.setlist.fm/rest/1.0/artist/b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d -H 'x-api-key: [youapikey]' -H 'accept: application/json'

works for me from localhost.

Re: Curl returns forbidden

Posted 10 Jan 2019, 9:29:38

Nice I got it working on my command line, I didnt know what curl was either. Im brand new to all of this. So I can only access the setlist API from the command line and not using regular ajax/XMLHttpRequest?

Re: Curl returns forbidden

Posted 10 Jan 2019, 9:33:18

Seems like it's about exposing the API key again. This entry about CORS might shed some light on the issue.

Post Reply

You're not allowed to do this, please sign in first.