Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Pass dynamic authorization token to tRest component

Hi,

 

I need to pass authorization token coming from one api to another api using tREST component. When I try to use context variable to store the token and use it in tREST component it is failing while working when hard coding the token can u please help.

 

0683p000009LwJW.jpg

Labels (2)
18 Replies
Anonymous
Not applicable
Author

Hi,

Please find below the screenshot

 

0683p000009LwFb.jpg

 

Output

0683p000009LwTQ.jpg0683p000009LvNO.jpg

 

After tJavaRow the component does not gives OnSubJobOK link

Anonymous
Not applicable
Author

That looks like a rather large "token", but I am assuming that you simply copied and pasted it when you tried your hardcoded solution which worked? I am also assuming you tested this by printing the value of the context variable. If so, this sounds like a timing issue. I suspect that the tRest component is being triggered to start it's initialization code before the context variable is set. To get round this you can use the OnSubJobOK link as I suggested. However, I wasn't explicit last time. You need to link this from the first tRest to the second tRest. Give that a go

Anonymous
Not applicable
Author

but I am assuming that you simply copied and pasted it when you tried your hardcoded solution which worked?

Yes, it worked with just copy paste.



I tried with SubJobOk too, no luck 0683p000009MPcz.png




Anonymous
Not applicable
Author

I can't believe I missed this.....I think I have spotted your issue. You are setting your token like this....

 

String var_FINAL_TOKEN = "\"Bearer "+var_TOKEN_1[0].replaceAll("\"","")+"\"";

That will create a String which starts and ends with a quote. Your service will not want this. Simply remove the \" from before Bearer and the +"\"" from the end of the line. 

 

The reason this worked when you copied and pasted it is that with the quotes surrounding the text, turn this into a literal String when you paste it into the header field.

 

Anonymous
Not applicable
Author

Hi,



Thanks a lot it worked. It was indeed timing issue. The OnSubJobOk and removal of quotes worked. Thanks a lot 0683p000009MACn.png


Anonymous
Not applicable
Author

You can probably go back to your original structure. The issue would have been caused by the quotes. There being a timing issue as well is unlikely....but not impossible 🙂

Anonymous
Not applicable
Author

hi @rhall 

Please i have the same probelem, but when i trying to connect tjavarow to TREST i just find rhe relation OncomponentOK, how can i do to connect it with onSubjobOK?

Thanks in advance

Anonymous
Not applicable
Author

Use the tRestClient component

Manoj_MUTHURAJA
Creator
Creator

Hi Pravin,

I'm also workin on the composant t_Rest.Does the issue solved for you?