Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
IliasTahri
Contributor
Contributor

Cant pass a global variable to tRest Http Body

0695b00000htcRHAAY.png

I'm trying to use a global variable that i defined before as parameter of

POST

http

body in the tRest component as follows :

0695b00000htcrkAAA.png

but im getting the " unable to decode malformed json "

Do you know a solution ?

Labels (4)
4 Replies
Anonymous
Not applicable

Hi

the expression syntax is not right, to use a global variable in a string, the expression looks like:

"...params\":["+(String)globalMap.get("session_id")+"]}"

// BTW, you need [] around the session id value in your case?

 

Please try again and let me know if it works.

 

Regards

Shong

IliasTahri
Contributor
Contributor
Author

i tried your suggestion but i still get the same error.

Yes i need the [] around the session id value because im working with an API that requires the [] in the params value .

Anonymous
Not applicable

Hi

Try to print the value of global variable before it is used to check if it has the right value. eg:

tBufferOutput--main--tSetGlobalVar

|onsubjobok

tJava

 

on tJava:

System.out.println((String)globalMap.get("session_id"));

 

In addition, have a try to set a fixed session id in the body string to test if JSON format in body is fine.

"...params\":[your_session_id_value]}"

 

 

IliasTahri
Contributor
Contributor
Author

that is not the issue.. the problem is that the error " unable to decode malformed json " so even if the session_id value is incorrect i should get a response other than the error above

 

i've also tried to hard code the session key to test the json format and it works fine ..

I'm starting to think its not possible to use a global variable in http body with json format