Help with POST Request

Hey guys,
I’m brand new to API’s so go easy on me. I’m trying to send a query to the setlist.fm API. I want to send the band name and the event date, then have it give me the location of the concert and the url to the page of the setlist. This is what I’m sending to the Post Request node:
[ {
“artistName” : “American Head Charge”
“eventDate” : “2000-06-11”
“format” : “json”
“url” : true
“venue” : true
} {
“artistName” : “Coal Chamber”
“eventDate” : “1997-09-13”
“format” : “json”
“url” : true
“venue” : true
} ]

I keep getting a “forbidden” error. I have my API key entered in the request header as an x-api-key entry and the connection url is https://api.setlist.fm/rest/1.0/search/setlists.

Any idea what I’m doing wrong?

Hi @siperwrx , are you sure this is a POST request rather than a GET request?

Looking at the swagger doc for setlist.fm it looks like this should be a GET

4 Likes

Hi @siperwrx

If you stick to this config then you should get the requested data :wink:

Output:

3 Likes

Instead of putting the artist in the connection query, how can I get it to read multiple entries from my table? I’m getting a 404 error now:

For that you would need to construct the GET request query (String Manipulator, Column Expression node) and put all those request in a loop with a Table Row to Variable Loop Start. In the GET Request node, make the connection URL flow variable controlled.

I’m not sure how you got the JSON column there but that won’t do anything for this particular API. It’s all query based :wink:

1 Like

So each query should look like this?
https://api.setlist.fm/rest/1.0/search/setlists?artistName=Slipknot&eventDate=1998-10-15

Yes, that’s correct.

If you go to the Swagger documentation, you can fill in values for the different parameters and click Try it out! It will then automatically provide the correct URL that you can use in KNIME to get the data. Also mind stuff like date formatting which is different from what you originally have.

https://api.setlist.fm/docs/1.0/ui/index.html#!/%2F1.0%2Fsearch%2Fsetlists/resource_1_0_search_setlists_getSetlists_GET

2 Likes

I’m getting so close, but it’s still not working. Here’s my setup:



image

Any other ideas? (You’ve been super helpful so far, I really appreciate it!)

I realized, based on your other post that my date was formatted incorrectly. So here’s an example of the exact URL I’m trying to pass on using the variable:
https://api.setlist.fm/rest/1.0/search/setlists?artistName=coal%20chamber&date=15-02-1998&p=1

It matches exactly what the Swagger URL is so there must be something wrong with how I’m passing the variable?

1 Like

Almost there! The variable should be set to Constant URI in this case.

Input:

GET:

Result:

Also note that this API has a fair use policy of max. 2 request per second for the free option. Since you are looking to iterate through a list, enable the delay option in the GET Request node to avoid that the API will bounce your request due to this (in case you are using the free option).

2 Likes

I’m getting results! You’re the best! I’ve hit one last snag if you don’t mind taking a look. I’m trying to parse the XML using the XML Reader, but it’s not recognizing the variable I created using the Table Row to Variable node. Any ideas what I’m doing wrong?

1 Like

xml reader is just reading xml. If you like to extract values from your column to xml node you can use xpath nodes
br

3 Likes

Got everything working now. Thanks everyone for the help!

1 Like

Please mark it as solved so that other KNIME users with a similar problem can find a solution quicker :slight_smile:

As mentioned, xpath queries are indeed the way to go as xml reader is the long way home.

1 Like