How to use a variable set earlier in a microflow as a http header

0
I have set a variable called Bearer as the value I want to use as the Authorization header. When I copy / paste the value of what I have assigned into the Bearer variable I get a response:       If I try and reference the variable as $Bearer I get a 401 unauthorized error:     Any ideas on how I reference the Bearer variable as a http header?
asked
4 answers
0

Hello Nathan,

 

It looks like that for the consumed rest service you need to use a different annotation for variables/tokens.

image.png

please see also the documentation https://docs.mendix.com/refguide/consumed-rest-service/#add-headers

So instead of using $ you need to use brackets.

 

Hope this helps,

 

Good luck!

answered
0

Hello Nathan Poulton,

You can simply achieve this by using constant,Variable or saved that value in any entity attribute. Please check the blank space in your defined variable.

image.png

image.png

answered
0

Yes - checked using Postman too and works fine there.

 

It works inside the http request when I debug if I copy the value in the Bearer variable into the header (the first screenshot), but when I try and reference the variable itself then it looks like it is not reading the value in the variable.

answered
0

I have recreated my Get request using the Call Rest operation rather than the Send REST Request. This then seems to undertand the variables - i.e. when you type the $ then you get intellisense of the variables loaded. This then send the request successfully and you get the expected data back.

answered