Rest call with curly braces

Highlighted
Four Stars

Rest call with curly braces

Hi, 
I'm calling the facebook API with tREST and when adding the time_range to the URL the job fails. 
The call works fine when testing in postman but it seems that Talend has problem with the curly braces {}. 

My URL is: "https://graph.facebook.com/v3.1/6063275471072/insights?fields=campaign_id,campaign_name,clicks,impre...time_range={since:'2018-08-21',until:'2018-08-21'}&access_token=***"

The Error is: Exception in component tREST_1 
java.lang.IllegalArgumentException: Illegal character in query at index 124

I tried different brackets, context variables and backslash \{ 
but I can't make it work. Can anyone give me a hint ?

Tags (1)

Accepted Solutions
Ten Stars

Re: Rest call with curly braces

I prefer to use tSystem with a cUrl command...
However since and until should be within quotes as what the api is telling me.
'since':

Im not sure if the url is encoded into a safe url by the tREST component, check your call by using fiddler or similar software to find out / debug whats happening on a lower level.

View solution in original post


All Replies
Ten Stars

Re: Rest call with curly braces

I prefer to use tSystem with a cUrl command...
However since and until should be within quotes as what the api is telling me.
'since':

Im not sure if the url is encoded into a safe url by the tREST component, check your call by using fiddler or similar software to find out / debug whats happening on a lower level.

View solution in original post

Four Stars

Re: Rest call with curly braces

Thank you Dijke!
curl in tSystem was a good tip. I made it work there.
Ten Stars

Re: Rest call with curly braces

Make sure the cUrl is called like this:

search for tSystem and bash array or something to load it in the same bash environment ... below an example on how I do it:

new String[]{"bash","-c","curl -k -L -v -c "+((String)globalMap.get("cookiesFolder"))+"/cookie.txt  https://somefreakingurl/login -d 'login=login&username="+context.Usr+"&password="+context.Pwd+"'" }

 

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

Have you checked out Talend’s 2019 Summer release yet?

Find out about Talend's 2019 Summer release

Blog

Talend Summer 2019 – What’s New?

Talend continues to revolutionize how businesses leverage speed and manage scale

Watch Now

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog