POST Request node does not send headers to web service

Hi!

When I send POST request from Postman, I recieve successful response from web service. But when I send exactly the same POST request from KNIME, the status I recieve is 401 unauthorized (authorization header with token included).

I checked my outgoing requests with Wireshark and saw that the length of KNIME request is shorter than the Postman’s one (77 bytes vs 416 bytes). KNIME request does not contain headers (authorization header with token). The confirmation of this issue is that web service log file doesn’t contain any headers sent by me from KNIME.

KNIME request

Postman request

The difference between two requests above is in “User-Agent” header. I tried to change the value of “User-Agent” header in KNIME POST Request node but I still face the same
authorization issue.

I also tried different options in POST Request node (“Trust all certificates”, “Follow redirects” etc.) but it does not fix the issue.

As for test I sent several requests from KNIME to different web services and everything worked successfull.

Thank you!

Hi @Tokbanov

How have you configured the POST request in KNIME?

Hi,
As @ArjenEX wrote, it would be helpful to see screenshots of your POST Request node’s configuration. Additionally, I can recommend using the endpoint https://httpbin.org/anything for testing (with dummy data). It’s a helpful webservice that sends back everything that it received in JSON format, including the headers. It is more convenient than using Wireshark, I’d say.
Kind regards,
Alexander

3 Likes

Here is my POST Request node configuration

Connection configuration
conn

Headers configuration
header

Hi @Tokbanov,

do you know whether your URL is redirecting? You can check this via command line tools or via browser developer tools. We know that our REST client nodes currently do not re-transmit credentials to every redirect location. Adding this option to REST client nodes is tracked in ticket AP-19962.

If you observed the first outgoing request to lack the authorization header already, redirecting is not the issue here.

Best regards,
Leon

3 Likes

No, there are no redirections except from HTTP to HTTPS.

“If you observed the first outgoing request to lack the authorization header already, redirecting is not the issue here.” - unfortunately I didn’t understand what you mean here.

The interesting thing is that GET request works successfully if I use Palladian HTTP Retriever but same request fails in GET Request node with the same authorization issue.

1 Like

Hi,
Have you tried httpbin to check what arrives at the server?
Kind regards,
Alexander

Hi,
Yes, I have tried httpbin and I see that headers arrive.

Hi,
so HTTP redirects work by the server sending a new location to the client, then the client attempts a connection to this new location. We know that in subsequent connections to redirect locations the credentials are not transmitted, but in the first request they should be. And you already confirmed this by seeing your headers being echoed from httpbin. So, it still could be a redirecting issue.

Second, although I doubt this being the issue: have you tried exactly matching the headers sent by Postman? For example, I can see that KNIME does not send Accept-Encoding headers which Postman sends.

Apart from these guesses, I can’t really investigate further. If you come across a public service showing the same issue, please share it so we can look into that.

Best regards,
Leon

1 Like

Hello, KNIME Community!

This is the solution for my question:)

But the interesting thing is that my Python and JS codes with POST request work successfully with and without trailing slash at the end of API url?!

Sorry and Thank You!