Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
SR2210
Contributor

Using context variable in tFixedFlowInput

Hello,

I have an issue where i want to write an API body request in tFixedFlowInput component. My job looks like below image

0695b00000KBtWsAAL.jpg

In tFixedFlowInput, i write the body request like this and it works fine.

{"name":"all","group":"all","level":"all","frequency":"yearly","start_date":"2021-10-01","end_date":"2021-10-31"};

However I would like to define the date as context variable since it might change from time to time. I tried to put it like this but it doesn't work

{"name":"all","group":"all","level":"all","frequency":"yearly","start":+context.start+,"end":+context.end+};

I also tried with double quotes, single quotes, still it won't fetch the data. Can anyone help how should i put the context variable there? Thank you

Labels (3)
3 Replies
XJ_1630
Contributor III

 

the whole string (json) has to be treated as a string in Java

 

thus any required double-qutes by JSON - have to be skipped in Java

 

try something like this:

 

 

 

"{\"name\":\"all\",\"group\":\"all\",\"level\":\"all\",\"frequency\":\"yearly\",\"start\":"+ context.start + ",\"end\":" + context.end +"};"

 

Note: the double-quotes around the variables are not skipped by a backslash

 

 

gjeremy1617088143

Hi could you send a capture of the working tfixedflowinput ?

I suppose you use personalise content:

it will read it as base64 and decode it that's why it's only reading it as a pure string and not permit you to use context variable

 

instead maybe you can use the first option : one row table and set it as a string in the schema and use escape char like this:

 

"{\"name\":\"all\",\"group\":\"all\",\"level\":\"all\",\"frequency\":\"yearly\",\"start_date\":\""+context.start+"\",\"end_date\":\""+context.end+"\"};"

 

send me love and kudos

 

 

gjeremy1617088143

we think the same thing a the same time 😉

you're right XJ_1630 you just have to add an escape doble quote before and after context var