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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
DScolari1623331702
Contributor
Contributor

Talend: How can I set global variable into tREST HTTP Body?

I am developing a new REST webservice for our application.

My goal is to pass instead of the fixed date, a date that I retrieve from a database ,

but as I report in the images below the parameter does not work correctly.

While if I pass the date as per the field below the job works correctly.

Would you know how to help me. Thank you

" {

"tokenKey": "ofsodfdsnsd frrfmoic",

"dbKey": "dd_ab",

"customerKey": "lp_ProdG100",

"from":"2022-11-01",

"period": "DAY",

"profile": 1

}

"

0695b00000aDR7dAAG.png

0695b00000aDR7iAAG.png

Labels (5)
1 Solution

Accepted Solutions
Anonymous
Not applicable

You appear to have a space between your globalMap containing the date and your opening double quote ("). You have...

 

\"from\":\" "+((String)globalMap.get("oggi"))+"\",

 

....and I think you need....

 

\"from\":\""+((String)globalMap.get("oggi"))+"\",

 

A tiny change, but it would end up producing your date like this....

 

" 2020-11-01"

 

...instead of this....

 

"2020-11-01"

View solution in original post

13 Replies
Anonymous
Not applicable

Hello @Davide Scolari​ ,

Regarding to your job snapshot, you can get the date value by globalMap.get("row93.oggi")

please reset it in the HTTP Body of tREST component to re-try?

 

Best regards

Aiming

 

DScolari1623331702
Contributor
Contributor
Author

Sorry, but I didn't quite understand.

I tried to rewrite the code in the following way:

 \"from\":\" "+((Date)globalMap.get("row93.oggi"))+"\", 

 

is correct, but no data is returned. 

Anonymous
Not applicable

Another way is to setup a Customize key for the tFlowToIterate component in the job like the below

then rewrite the code in tREST body like

\"from\":\" "+globalMap.get("oggi")+"\", 

0695b00000aDREAAA4.png 

DScolari1623331702
Contributor
Contributor
Author

Thank you, I think I have identified the error.

Instead of just returning me '2022-11-02' it gives me '2022-11-02 00:00:00' consequently it goes into error. I don't know how to force it

0695b00000aDRGBAA4.png

Anonymous
Not applicable

@Davide Scolari​ , in the tDBInput_2 component schema settings, please reset the column oggi Date Pattern to 'yyyy-MM-dd' like the below, then re-try the job?0695b00000aDRLGAA4.png 

DScolari1623331702
Contributor
Contributor
Author

Thank you, but I had already tried but it doesn't work

Anonymous
Not applicable

@Davide Scolari​ , you can substring the oggi value, in the tREST body , try the below

\"from\":\" "+globalMap.get("oggi").toString().substring(0, 10)+"\", 

DScolari1623331702
Contributor
Contributor
Author

Thank you, but you expect a Date the Trest . I discovered this by running the job in Trace Debug

Anonymous
Not applicable

A date passed via a web service will either be passed as a String or a number. A Date in Java is essentially a number that when it is shown to users as a String, can be formatted in a number of different ways. If the error is caused by not receiving "2022-11-02", then your date is arguably expecting a String.