Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
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
aolmo
Partner - Contributor
Partner - Contributor

Hi!

 

I see that you don´t have an space after "Bearer".

 

Try with -> "Bearer "+globalMap.get("row11.access_token")

 

With an space after Bearer string

uzix
Creator
Creator

hello,

 

several issues:

-assign the extracted value value to a globalVar - pic1+pic2

-get the value and use it in auth - pic3 ("Bearer<space>" + globalMap.get("token") 


pic1.jpg
pic2.jpg
pic3.jpg
Anonymous
Not applicable
Author

Hi @uzix,

 

Thank you for your valuable comments. Yep, Now i tried to fix the problem some what based on your comments and  i am able to pass token to tHttpRequest. But still I am getting same error. Please find the attached screen shot. 

 

Will there be issue with post parameters from file option, i tried to post direct json file as well json pasted in text file. but still getting same error. is my approach towards posting json to rest service is correct. Please find the attached screen shot of that component as well and suggest me how this can be approached.

 

Thanks in advance.

 

 


tHttpRequest_.PostParameter.JPG
UpdateJob_error.JPG
aolmo
Partner - Contributor
Partner - Contributor

Can you try with tRestClient component with json as input to send POST request?

 

 

uzix
Creator
Creator

Hello,

 

good.

 

are you able to post with params via postman for example?

 

in the file used to retrieve the params do you have something like:

param1=valueOfparam1;param2=valueOfparam2

 

?

Anonymous
Not applicable
Author

Hi @uzix in postman i will be posting as follows,

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

while in tHttprequest i am referencing a txt file which has that full json string in below format,

 

 
{"body":[
{"val1":"10580","val2":"82748","val3":"1226","val4":"155"},
{"val1":"2300","val2":"82548","val3":"1326","val4":"145"}
]}
Anonymous
Not applicable
Author

Hi @Moe,

 

Thank you for your comments. yea I tried with  trestclient, but may I know how we can post json to trestclient, as i tried with tfileinputjson component but i am not able to connect two component. can you suggest me how to post json to trestclient what component we can use.

 

Thanks in advance.

uzix
Creator
Creator

hello,

just trying to understand some points:

do you  post via postman with sucess?

- you post as urlencoded ?  --> the key is "DETAILS"  and the value is the json ? 

 

Anonymous
Not applicable
Author

Hi  @uzix,

 

yea, exactly you are right. I post as url encoded with the key as "DETAILS"  and the value is json.

 

And when i tried it with posting same in postman, i am getting success response.