tREST http body problems using global variable

Five Stars

tREST http body problems using global variable

Hi

 

I struggle to get a Zuora API call right in the rRest client. The API wants a JSON body as input.. 

 

 

HTTP POST body:

 

"{
\"queryString\": \"select id, name, subscriptionid from Rateplan where id='abcdef123456' \"
}"

 

=> this works OK. But then getting the variable from database with tFlowIterate, it doesn't work:

 

1:

"{
\"queryString\": \"select id, name, subscriptionid from Rateplan where id=\" + ((String)globalMap.get("rateplan_id")) + \"
}"

 

=> invalid assignment

 

2: 

"{
\"queryString\": \"select id, name, subscriptionid from Rateplan where id=\" + ((String)globalMap.get(\"rateplan_id\")) + \"
}"

 

=> malformed POST body content

 

3,4, 5 => other issues

 

 

What's the correct format of using global variable in the POST BODY?

 

 


Accepted Solutions
Sixteen Stars

Re: tREST http body problems using global variable

Try this.....

 

"{
\"queryString\": \"select id, name, subscriptionid from Rateplan where id='" + ((String)globalMap.get("rateplan_id")) + "'\"
}"

You are concatenating Strings. When you close the JSON String before concatenation, you do not need to escape the ". You also missed the single quotes (').


All Replies
Sixteen Stars

Re: tREST http body problems using global variable

Try this.....

 

"{
\"queryString\": \"select id, name, subscriptionid from Rateplan where id='" + ((String)globalMap.get("rateplan_id")) + "'\"
}"

You are concatenating Strings. When you close the JSON String before concatenation, you do not need to escape the ". You also missed the single quotes (').

Five Stars

Re: tREST http body problems using global variable

thanks, seems to work. I tried also with single quotes, but this was probably the point of confusion I suppose:

"When you close the JSON String before concatenation, you do not need to escape the "."