extracting the JSON response from tRest component

Six 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
Thirteen 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
Highlighted
Thirteen 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

-----------
Six 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 

Thirteen 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

 

-----------
Six 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.

Six 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!!

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.