How to use and share a cookie from authentification API REST call?

2
First of all, I am using Mendix 8.6.0 (build 715). [the choice was not available to me in the drop down menu] I want to design a Proof of Concept (PoC) showing that Mendix can connect to a Bonita database through REST API calls. I just want to connect to the Bonita service, get some data (for instance, a object of “Employe” type) and then disconnect from the service. My main microflow looks like this: When I connect to my service via Postman, I get a token cookie for the session (called X-Bonita-API-Token for instance), which I have to copy and paste for all the subsequent REST API calls: How can I use it in Mendix as a parameter for my second API call? So far, I guess I have to specify it as a Custom HTTP Header, but I just cannot find what is the correct expression to put in the “Value” field. I am actually wondering where this token is stored in my Mendix application. Did I have to specify an import mapping as a response of the first authentification API call? Edit: The cookie I am looking for is located in the response header in Postman: But when I have a look at the REST calls log (at “trace” level), I can only see one “Set-Cookie” header, and not the one I am looking for: Is this part of my problem, also?
asked
3 answers
2

As Reinout said you can retrieve the list of HTTP headers by association of the $latestHttpResponse/HttpHeaders:

 

After this you can loop over them or do a find(list operation) to retrieve the JSESSIONID & Bonita token:

 

Hope this helps.

answered
0

The httpresponse will have a header list connected. YOu can retrieve the list and loop over the list to find the right header. Then you have the vlue you can send with your next request 

answered
0

Hi Olivier
Did you find what's the issue?

answered