formatting a Post Request

I am hoping someone can help me. I am trying to obtain an OAuth token via a post request to Wild Apricot. Looking at their documentation it says I need the below. But I can’t figure out how to get it all into the KNIME Post Request node so that it works. Can anyone help with how to set this up? I have my API key and I can encode it into base64 with no issue.

POST /auth/token HTTP/1.1
Host: oauth.wildapricot.org
Authorization: Basic BASE64_ENCODED(“APIKEY:YOUR_API_KEY”)
Content-type: application/x-www-form-urlencoded

grant_type=client_credentials&scope=auto


Here is an example with a nonvalid API key
POST /auth/token HTTP/1.1
Host: oauth.wildapricot.org
Authorization: Basic QVBJS0VZOm85c2U4N3Jnb2l5c29lcjk4MDcwOS0=
Content-type: application/x-www-form-urlencoded

grant_type=client_credentials&scope=auto

To be honest, I would contact them to help you out. As per usual, their documentation is unreliable. The API via a POST request in KNIME returns a 405 but it’s not even documented what this means to them :roll_eyes:

This could be an alternative:

I told it to output the error code and I am getting this: “Response doesn’t have a media type”

Any ideas?

Hi,
This sounds like the server does not send a content-type header and KNIME does not know how to interpret the data it receives. However, in KNIME we could work around this by defaulting to the output of a binary object cell, which you could then treat however you liked (e.g. using Binary Objects to Strings). I have created a ticket for our developers to implement this. The internal number is AP-21564.
As this will not help you now, you may be able to use this POST Request component I published a while ago: Custom POST Request – KNIME Community Hub. Here you can choose a body column containing grant_type=client_credentials&scope=auto, and you need another column named Content-type with the content application/x-www-form-urlencoded and another one named Authorization with your base64 encoded API key as content. Then you can select the latter two columns under “Header Columns”.
Kind regards,
Alexander

1 Like

thanks, I am trying to get this to work, but there are no examples for this node. I cant get it to accept any column as the body, it only shows … and has no drop down to select the column. Could you provide any details on how to specify the body text for this node?

Hi,
Please find an example here. I made input and output body a binary column so it is more versatile. That’s why your string column cannot be selected.
Kind regards,
Alexander

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.