I am currently switching from Postman to Thunder Client in VS Code. Most request which I called from Postman worked without a problem in the Thunder Client. But currently I am stuck at a specific request. The request is a POST Request which is used to option a Bearer Token and uses the Content-Type "application/x-www-form-urlencoded".
In Postman the request works without a problem Authorization: "Basic Auth" with username and password (yes you need two different passwords and users for the API) Headers: Content: application/x-www-form-urlencoded Body (x-www-from-urlencoded Option):
grant_type password
username {{username}}
password {{password}}
In Thunderclient there is no x-www-from-urlencoded Option. So I assumed that either the Form Option (Chat GBT told me that that one should work) or the Text Option should work. According to the documentation of the API the content header has to be application/x-www-form-urlencoded
so I cannot change this one to something like Json.
If I put the following in the "Form" Option (basically the same as in Postman and yes I have set the environment variables accordingly and tested it with the true password and user):
grant_type password
username {{username}}
password {{password}}
I get:
{
"error": "invalid_request",
"error_description": "The token request must specify a 'grant_type'. Valid values: [password]"
}
Also if I try to put grant_type=password
in the Text Option I get the same error. (Yes I have also tried this with many variation of with and without password. But according to this post this should be the correct syntax. I have also tried all possible combinations of putting the key and value in quotation marks.
From the error message I can read, that he somehow cannot find the value for grant_type but I cannot figure out why. The only idea I still have is to somehow look at the finished message to find out how the body looks. But I do not know how to do this yet.
Using Form-encode
of Body
Comparison table of the body input types between Postman and Thunder Client
Postman | Thunder Client |
---|---|
form-data | Form |
x-www-form-urlencoded | Form-encode |
raw | JSON |
binary | Binary |
GraphQL | GraphQL |
Launching Keycloak by Docker Compose in here
Example for Keycloak Master Token by Thunder Client