I desperately need your help after spending a day with useless attempts to solve the common task – send request to remote API. Not the first time when I am dealing with this matter, but this time I failed.
Here’s the case:
I would like to enrich my data with Siret API. API provides access to corporate records of France. API is opened for public, free, but requires registration of the user and token’s regeneration ones a day.
That’s what API provider would like to have as an input:
I was sure that it’s not a big deal and made the following simple workflow (simple it became by the end of the day when I accepted the fact that I can’t easily inject the data to my main workflow, so I’d like to make something extremely simplified):
curl.knwf (9.9 KB)
The reply of the server is:
xmlns:ams=“http://wso2.org/apimanager/security”>ams:code900902</ams:code>ams:messageMissing Credentials</ams:message>ams:descriptionRequired OAuth credentials not provided. Make sure your API invocation call has a header: “Authorization: Bearer ACCESS_TOKEN”</ams:description></ams:fault>
What could I possibly did wrong this time?
Thank you very much and have a good weekend!
Hi @DmitryIvanov76 , I checked your workflow, and I’m not sure you understand what’s being done there…
- cURL is a command line tool that you can use to send http requests such as GET, POST, etc, so you do not send curl in your Request, neither as body nor as headers.
- In your POST Request, you are passing about 16 headers, and all but one of them are empty. And that’s the Content-Type, which you define as “application/x-www-form-urlencoded”, but you define it as “text/plain; charset=utf-8” in your POST. You basically need to pass 3 headers here as per the api documentation for POST:
It works for me via the Knime POST Request:
Here’s my POST Request workflow:
POST Request for Sirene V3.knwf (5.2 KB)
The only thing that was tricky here is that it looks like there are some confirmation to accept/trust the SSL certificate for the https. This is overcome by checking this box:
This is exactly the help I needed!
You are certainly true - curl is something above my understanding - previously I dealed with APIs working with simple request, but your workflow opens a lot of new opportunities to me!
Have a great rest of the day and thank you very much for your expertise!
No problem @DmitryIvanov76 . The cURL command is just something you’d use on the command line.
Regarding the workflow, you can obviously parameterize it by passing values to the POST Request node via a table (for example the values for q=)
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.