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: 
Anonymous
Not applicable

Consume Token from Rest API and post that token and json to tHttpRequest

Dear All,

 

I am trying to develop a talend job that gets token from tRest component in json format where i tried to extract the token using tExtractJSONField and later I want to post a json(test.txt) along with the token to tHttprequest. But I am getting following error status,

 

{"status":"Failed","response":"Object reference not set to an instance of an object.","message":"Insert failed."}

But when i tried to replicate the same using postman it was working. Below I have attached screenshot of my talend job and my test scenarios which I did in postman for reference. Please assist me in providing work around for this error and let me know if you require further information.

 

Thanks in advance.

Labels (2)
30 Replies
uzix
Creator
Creator

okay,

 

maybe try this:

 

-use fixed values to test: pic4

-build json using twriteJSONField -  pic6  -> check the "remove root node"

-set the output of twriteJSONField as type String and column name "json"  - pic7

-->|{"body":[{"val1":"10580","val2":"82748","val3":"1226","val4":"155"},{"val1":"2300","val2":"82548","val3":"1326","val4":"145"}]}|

-use the trestclient and set the query parameters accordingly and the input schema - pic8 + pic 9


pic4.jpg
pic6.jpg
pic7.jpg
pic8.jpg
pic9.jpg
uzix
Creator
Creator

using a file as input, try this, more simple:

 

-create csv file .

-use tFileInputFullRow and point to csv

-confirm: output schema of tFileInputFullRow is "line"

pic10

tRestClient:

configure as in pic11


pic10.jpg
pic11.jpg
Anonymous
Not applicable
Author

Thank you @uzix .

 

I tried with above option using tRestClient and passing json through delimited file. But still the response from API is getting failed. Please find the attachment for your reference.


tRestAPIError.JPG
uzix
Creator
Creator

hello,

lets go step by step...

 

try with tFileInputFullRow as in the pic in above post

set the input of trestclient as in pic in above post

i see youre setting a json via twritejsonfiled and also using a tfileoutputdelimited in same flow.

i supose either you use a twritejsonfield to define your json or use a file output delimited with the "parameters"

copy the json you have working from postman to a csv file in a single line. like in pic12

use a tFileInputFullRow and point to said csv file

lets try do a simple flow :

tFileInputFullRow --> log --> trestclient (pic10)

if possible show:

-tlogrow4 log 

-the trestclient component definitions you have. -> like in pic11

 


pic10.jpg
pic11.jpg
pic12.jpg
Anonymous
Not applicable
Author

Hi @uzix,

 

yea i tried to replicate the same using tFileInputFullRow. But still I am getting the same error. 

Please find requested screenshots of the component tRestClient, tfileoutputdelimited and output error.

 

I have no clue what is the problem. If you could assist me it would be great. M

 

Thanks in advance.

 


tRestClientComponent.JPG
UsingtFileInputFullRow.JPG
tFileDelimitedoutput.JPG
uzix
Creator
Creator

 

in tlogrow sync columns and set your tlog 4 as  in pic.

whats the tlog4 result ? does it print the json ?

show the json

 

ty


pic_log.jpg
Anonymous
Not applicable
Author

Hi @uzix 

yea tlog4 prints json. Please find the attached screen shot of it and let me know if you require further information. 


tLogRow4.JPG
uzix
Creator
Creator

the json seems ok.

 

can you post the input schema of the trestclient?

Anonymous
Not applicable
Author

@uzix  yep, please find the attached screen shot of tRestClient Input Schema


InputSchematRestClient.JPG
uzix
Creator
Creator

ok,

 

try this:

-on tlogrow output remove the output "line"

-check input schema of trestclient is empty 

in trestclient  -> query parameter -> change the value of  row13.line to row12.line

 

images attached


pic1_.jpg
pic2_.jpg