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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
kakooo16
Creator
Creator

How to pass dynamic (body) values to tREST

Hello , 

 

So , im trying to a dynamic value to a tREST body query : (here is a screen shot of my trest configuration) :0683p000009M9U2.png

to Explain more  im getting an error as below   : 

0683p000009M9U7.png

When i use static values it works .

my job  is as such : 

0683p000009M9UC.png

I think that i have a syntax error in the query . 

 

Hope this problem would be solved . 

Thanks again .

 

Labels (2)
8 Replies
TRF
Champion II
Champion II

You need to use strings concatenation like this:

"{\"query\":\" blablabla
       product_simple_ids : [" + ((List)globalMap.get("myList")).get(i) + "]) blabla...
kakooo16
Creator
Creator
Author

Hello TRF ,

It seems like the error is caused by

((List)globalMap.get("myList")) : however the double quaotes are note supported in query ,so i ve put an \ to avoid them . But , seems that the problem still persist
kakooo16
Creator
Creator
Author

Here is my new query : 

 

product_simple_ids: [ \\\"+((List)globalMap.get(\"myList\")).get(i)+\\\" ])
kakooo16
Creator
Creator
Author

Is there a possible way to pass dynamic  global  variables and support the double quotes (") : such example :   

 

 

product_simple_ids: [ \\\"+((List)globalMap.get(\"myList\")).get(i)+\\\" ])

 

Im still blocked and needs some help please . 

Thanks in advance .

TRF
Champion II
Champion II

The basic rule you have to respect is that fixed parts must be between " but not variable parts issued from variables. Inside fixed parts, " must be protected by \.
Here is an example:
"a fixed string with \" inside"
kakooo16
Creator
Creator
Author

Thanks for your helpful advice ! I get it now but i have an other error . as shown below :0683p000009M8x9.png

In the first line am printing my global variable OK but it seems like it is treated separtrly (in blocs ) some how as in the screenshot . 

 

I don't realy get the error ! 

Any idea ? 

TRF
Champion II
Champion II

Can't see the problem. Body field contains \n so it's printed on multiple lines. If it disturb the next component behaviour, remove them with something like row1.body.repalceAll("\n", "")
kakooo16
Creator
Creator
Author

And for the first element treated im getting this  : 

marketplace_product_id to be  treated ==3ME-K110032032
.----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------.
|                                                                                                                                          tLogRow_1                                                                                                                                          |
|=---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------=|
|Body                                                                                                                                                                                                                                                                              |ERROR_CODE|
|=---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------=|
|{
    "errors": [
        {
            "message": "Syntax Error: Invalid number, expected digit but got: \"K\".",
            "locations": [
                {
                    "line": 1,
                    "column": 130
                }
            ]
        }
    ]
}|null      |