How to correctly use HTTP headers and authentication for the Call REST Service activity.

0
Dear Mendix Community,   For our association we want to connect our Mendix app to our website hosted by a third part. They have a REST API for us to connect with, and we succeeded in doing so with Python as a test. Currently we are trying to get it to work in Mendix, but are unsure of how to do it exactly.   The export/import mapping, JSON structure and microflows are set-up. We are getting a 401 (Unauthorized) response, leading to the conclusion we are doing something wrong with the HTTP headers.   This is the information supplied by the third party regarding the topic, and for specifically regarding the blogs (which we are trying to GET/POST), as well as the HTTP response:       And the following being the latest thing we tried, with “APIKey” being a string received from the third party as mentioned above:     Any information or tips on how to proceed are welcome!   Kind regards,   Hugo
asked
3 answers
0

Hello Hugo,

You can add new HTTP header with Key “Authorization” & Value 'Bearer '+ $AccessToken/Token

answered
0

Dear Mohamed,

 

Thank you for your response, is this what you meant? (it did not work yet, got the same response)

 

answered
0

Hi Hugo, 

This is how we set up an API with a bearer token, hope this helps (same solutions as above):

For testing API’s we use Postman (https://www.postman.com). You can test, add headers and play around and if you get it to work in Postman, it’s easy to implement in Mendix as well. 

What headers did you use in Python? They should be the same for your Mendix app.

answered