extracting the JSON response from tRest component

Eight Stars

extracting the JSON response from tRest component

Hi,

 

Im making an API call to silverpop(using tRest component) to obtain the access token, passing the client id,client secret and refresh token. I'm getting a JSON response in the below format

 

{"access_token":"xxxxxxxxxxxx","token_type":"bearer","refresh_token":"xxxxxxxxx","expires_in":11169}

 

I want to be able to be able to save these in a delimited file and assign the access token to a context variable so that I can pass its value in the next API call.

 

Please give me a detailed explanation as this topic totally confuses me.

 

 

Thanks in advance for any input that you may be able to give me


Accepted Solutions
Highlighted
Forteen Stars

Re: extracting the JSON response from tRest component

oh :-)

 

sorry!

 

of course, you haven't it, because it is tExtractJSONFields - https://help.talend.com/reader/wDRBNUuxk629sNcI0dNYaA/fXKGrpQJBOMvM4G9ckjE7A

 

-----------

All Replies
Forteen Stars

Re: extracting the JSON response from tRest component

link response to tParseJSONFields tExtractJSONFields, than connect to tFlowToIterate

 

generally, that's all - tFlowToIterate already store values into global variables, you could use these variables anywhere in following connected subjobs

-----------
Eight Stars

Re: extracting the JSON response from tRest component

Hi @vapukov,

 

Thanks for your reply. But I don't have 'tParseJSONFields' component.I just have tFileInputJSON and tWriteJSONField components. May be because I'm using the trial license?

Please let me know of an alternate way to handle this. Thanks in advance 

Highlighted
Forteen Stars

Re: extracting the JSON response from tRest component

oh :-)

 

sorry!

 

of course, you haven't it, because it is tExtractJSONFields - https://help.talend.com/reader/wDRBNUuxk629sNcI0dNYaA/fXKGrpQJBOMvM4G9ckjE7A

 

-----------
Eight Stars

Re: extracting the JSON response from tRest component

Hi @vapukov,

 

Thanks for your reply.. Can you also please show me how it is done with tExtractJSONField component?

I tried doing it but was not able to as the JSON response is passed as a single string through the Body field of tRest component and I'm not able to separate the different fields.

 

This is my JSON response 

{"access_token":"xxxxxxx","token_type":"bearer","refresh_token":"xxxxxxxxx”,”expires_in”:14399}

 

And I want to be able to save these in a delimited file as key value pairs and assign the access token to a context variable.

Eight Stars

Re: extracting the JSON response from tRest component

Hi @vapukov,

 

I was finally able to get what I wanted with tExtractJSONField component.

 

Thanks much for your timely response!!

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch