Can't sent authorization header

I use Node.JS and try send autorization header in GET request to external API.
I successfully retrieve the token in the previous request and everything works fine in Postman.
But header not sending…
I’ve read in other posts here that fixing .htaccess helps in PHP, but what about Node.JS?

Isn’t that your response you are looking at? You won’t find the headers you sent there, you need to check the request headers that you’ve sent. Seems there’s some problem with the authorization, maybe you are sending a wrong value.
What is the value that needs to be sent in the Authorization header?

The expression is wrong, please try defining the content of the Authorization header in a Set Value step first so you can see if it’s being built correctly before attempting to perform the request

The expression is wrong because “Bearer” is not surrounded by any quotation marks, it’s supposed to be a string so it should be surrounded by quotation marks (otherwise it’s considered as a variable name)

{{ Bearer (...) }}
{{ 'Bearer' (...) }}
1 Like

I’m trying to extract a token from data - but for some reason this variable disappears altogether, although the response scheme seems to be normal

Bearer + token, but the problem seems to be that Wappler does not correctly take the data from the response, although the schema is recognized correctly

The API you’re trying to receive the access_token is not sending the correct Content-Type header for JSON, the data is a string, so you need to JSON decode it first (because it’s not done automatically due to the wrong Content-Type header text/html instead of application/json)

There’s a formatter for JSON decode, but I’m not sure if you can find it in the UI

You are absolutely right :slight_smile: Thanks for your help! Just wondering how Wappler parsed the answer and showed it as separate fields if there was a continuous line there? Is this some kind of not entirely correct behavior?

Indeed, looks like Wappler didn’t really look at the Content-Type header and simply tried to JSON decode the API response. You’re right it’s not the most correct behaviour :wink:

You’re welcome!

1 Like

The server connect action looks at the Content-Type header and decodes when needed. Since the header was text/html it didn’t parse JSON which is the correct way.

The schema editor within Wappler doesn’t look at the header and always tries to JSON decode the result. It should probably show some warning to the user that the Content-Type header of the remote api doesn’t match.

Yes, Wappler asks for JSON, but if don’t get it, you don’t need to display fields it in the schema, because it creates confusion that these fields can be used further.