REST Call in Mendix

Hi Everyone , I am working on a Mendix application where we are calling a REST Service to fetch some data but in order to that we need one more REST call to authenticate the session . If i am trying in chrome browser by simply putting the authentication URL in one tab and then calling data URL it’s working as cookies are validating the session.   How can i carry cookies from one REST call to another REST call in Mendix ?   Thanks 
2 answers

After the REST call, you can do a Retrieve action on $latestHttpResponse. There you will find the cookie.


I am not sure how to fetch cookies from the first REST-call and add those to the second one.


The most common way for this set-up is that you first call a REST-method and fetch an authentication token. This token is returned in the response body of the first REST-call. You save this token in a non-persistent entity and add it to the Authorization header of the second REST-call. In this way, the authentication on the second REST-call is handled. 

Here is a link to how Bearer tokens work, which is one possible method that I just explained:


I am not sure if this is exactly the right way in your case, as that depends on the owner of the REST-API and the way authorization is handled there. Hopefully this can help you to get a better understanding though.