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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

tHttpRequest custom parameter in file

Hi,

 

I have an API with parameter.

URI: "https://mysite.com/payment/query?"

There is parameter "load" which contain request. Currently i am loading the parameter value from txt file as below screenshot. But my problem is i have "<Period from='2019-02-15 00:00:00' to='2019-02-15 23:59:59'/>" in my request file, and this will everyday.

 

my param file contain: 

load=<?xml version='1.0' encoding='UTF-8'?><Request version='1.0'><Header><Security sender='xxxxxxxxxxxxxxxxxxxx' type='PSP'/></Header><Query mode='CONNECTOR_TEST' level='CHANNEL' entity='xxxxxxxxxxxxxxx' type='STANDARD'><User login='xxxxxxxx' pwd='xxxxxxx' /><Period from='2019-02-04 00:00:00' to='2019-02-04 23:59:59'/><Types><Type code='DB'/><Type code='RF'/></Types><ProcessingResult>ACK</ProcessingResult></Query></Request>

 

0683p000009M3Al.jpg

 

Please advise.

 

Thanks

 

 

Labels (3)
1 Solution

Accepted Solutions
akumar2301
Specialist II
Specialist II

One way , you keep your parameter file as template. In it assign from and to as variable like

<period from=stringtoreplace1 to=stringtoreplace2>

Everyday create a parameter file by replacing above variable using tjavarow/treplace etc.
Use newly created file in http component.

https://help.talend.com/reader/Y6cetClmMZDfpUVtVCFdow/kRnjfFJFBt1Un1P9oOzWyw

View solution in original post

3 Replies
akumar2301
Specialist II
Specialist II

One way , you keep your parameter file as template. In it assign from and to as variable like

<period from=stringtoreplace1 to=stringtoreplace2>

Everyday create a parameter file by replacing above variable using tjavarow/treplace etc.
Use newly created file in http component.

https://help.talend.com/reader/Y6cetClmMZDfpUVtVCFdow/kRnjfFJFBt1Un1P9oOzWyw

Anonymous
Not applicable
Author

Hi,

Thank you, i added tJava, added code and finally the whole request is formatted with date, and then write to a file in specific location. So now i will read same file with tHttpRequest.

The issue is file write take a small amount of time, and then it finishes, tHttpRequest give error C:\Users\myuser\Desktop\param.txt (The system cannot find the file specified).

 

using below code to write a file in tJava

mainText= String.format(mainText,frmDate,toDate); 

File newTextFile = new File("C:/Users/myuser/Desktop/param.txt");

FileWriter fw = new FileWriter(newTextFile);
fw.write(mainText);
fw.close();

I even tried the Thread.sleep but not helpful, also tried Trigger for OnSubJobOK.

 

Any advise?

Anonymous
Not applicable
Author

Finally it is like below. in tJava i am making a file with date. and then passing that to tHttpRequest.

Thank You @uganesh 

 

0683p000009M3AN.jpg