After logging into Zuora using RestClient, do I need the Access Token for further Zuora interactions?

Highlighted
Five Stars

After logging into Zuora using RestClient, do I need the Access Token for further Zuora interactions?

New to Talend, have gone through a few training videos and labs at Talend Academy, but struggling with building an integration which requires REST API calls.

I have successfully created the login call using tRestClient, and it returns something like this when hooking up with a tLogRow:

Starting job startZRsessionOAuth at 08:10 19/03/2020.
[statistics] connecting to socket on port 3827
[statistics] connected
200||{"access_token":"798c13cc31d3473d895c02e1812b5g7a","token_type":"bearer","expires_in":3598,"scope":"entity.19e643f4-a3ac-750b-b061-0025904c59d6 platform.write service.usage.delete service.usage.update service.usage.write tenant.12345 user.2c92a0f970e7e3390170ebfa5d4a2d6b","jti":"792c13cf31d3473d995c09e1312b5f7d"}
[statistics] disconnected

 

The problem is the "what's next"?

Tried isolating the access token under the assumption it is required for further REST calls, but failing miserably.

Tried tExtractXMLfield, tExtractJSONfields, even tSetGlobalVar, they would compile, sometimes even process a row, but the tLogRow I tied at the end of those never showed any output.

Also tried just putting a new REST call in, with a query I know that works. Simple setup with URL "https://rest.zuora.com/v1/action/query" and body "{
"queryString": "select AccountId from PaymentMethod where AccountId='2c72a0f951095f3d01512329fb5f59a2'"
}"

That doesn't even compile.

 

So what I am after are some pointers, or indications around which Talend video or training to view to get educated, or a specific piece of documentation that explains this.

 

Cheers!

Tags (3)

Accepted Solutions
Highlighted
Community Manager

Re: After logging into Zuora using RestClient, do I need the Access Token for further Zuora interactions?

Hi  

Use a tRest component to call API, the URL is:

"https://rest.apisandbox.zuora.com/v1/action/query/"

define the Authorization key/value in the Http headers list,

name   value

"Authorization"    context.bearer_token

 

and pass Http body as below:

"{
\"query_string\" : \"select paymentNumber from ...bababa....\",

} "

 

Regards

Shong

----------------------------------------------------------
Talend | Data Agility for Modern Business

View solution in original post


All Replies
Highlighted
Five Stars

Re: After logging into Zuora using RestClient, do I need the Access Token for further Zuora interactions?

Managed to get the access token isolated by using a tMap and tExtractJSONFields, so left with the question around how to then use the access token to run queries against Zuora (if indeed explicitly required).
There is unfortunately preciously little information I've found on how to use Talend for this... any help would be greatly appreciated

Highlighted
Five Stars

Re: After logging into Zuora using RestClient, do I need the Access Token for further Zuora interactions?

thought I could assign the access token to a context variable using tJavaRow, but for some reason it doesn't work

After ensuring the schema of tExtractJSONFields had the proper output attribute (just called "access_token") going into the tJavaRow component, I coded it thus:

 

globalMap.put("access_token",input_row.access_token);

However, the context variable remains empty.

If I give that context variable an initial value, it retains its initial value... sigh...

 

Thoughts/ideas anyone?

Highlighted
Community Manager

Re: After logging into Zuora using RestClient, do I need the Access Token for further Zuora interactions?

If you want to assign the value to context variable, the code is:
context.varName=input_row.access_token;

Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Highlighted
Five Stars

Re: I want to extract the values of few fields from tExtractJSONFields and update a Database record

Thanks Shong, a colleague pointed that out as well... it works :-)

 

Now I need to find some useful (read: insightful) documentation on how to use Talend components to use the REST API to issue simple queries like "select id from Payment where 'invoiceID=somevalue'", and run functions like "credit balance adjustment" (via

https://rest.zuora.com/v1/object/credit-balance-adjustment) using that access token.
Any suggestions?
Highlighted
Five Stars

Re: After logging into Zuora using RestClient, do I need the Access Token for further Zuora interactions?

Hey Shong, I just read your answer to another community post:

https://community.talend.com/t5/Design-and-Development/resolved-How-to-pass-tJava-output-as-header-d...

 

I am after the exact same thing, but for some reason the solution you provided doesn't work.

Will upload a few pictures:

1) how it works in Postman

2) how the 'base job' works in TOS, without the REST call

3) how that 'base job' fails as soon as I add the REST call using a context variable in its header

Here's the URL I call with tREST:

"https://rest.apisandbox.zuora.com/v1/action/query/"+(String)globalMap.get("bearer_token")

 

Any advice on what I am missing or misunderstanding?

Highlighted
Community Manager

Re: After logging into Zuora using RestClient, do I need the Access Token for further Zuora interactions?

Hi  

Use a tRest component to call API, the URL is:

"https://rest.apisandbox.zuora.com/v1/action/query/"

define the Authorization key/value in the Http headers list,

name   value

"Authorization"    context.bearer_token

 

and pass Http body as below:

"{
\"query_string\" : \"select paymentNumber from ...bababa....\",

} "

 

Regards

Shong

----------------------------------------------------------
Talend | Data Agility for Modern Business

View solution in original post

Highlighted
Five Stars

Re: After logging into Zuora using RestClient, do I need the Access Token for further Zuora interactions?

Thanks Shong.

I think it was specifically the escapes in the body that made the difference (as I had tried it with context.bearer_token as parameter as well, when I first set it up).

2019 GARTNER 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

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Self-service Talend Migration: Moving from On-Premises to the Cloud

Move from On-Premises to the Cloud by following the advice of experts

Read Now