[resolved] [R] Uing tRt t acc API

Highlighted
One Star

[resolved] [R] Uing tRt t acc API

I am trying to configure a multilayered job to extract information from a REST webservice. I am really close to getting it to work but am having some problems that I am hoping someone might be able to help me with.
The API I am trying eo extract from is Mongoose Metrics. The top level list I want to extract is given by the following URL...
http://www1.mongoosemetrics.com/api/api.php?function=list_account_campaigns&api_key=12345&account_co...
So I dropped a tRest component into a job and configured it as in the first screenshot. This does not work.
So I changed the configuration to simply put the whole URL in the URL field (second screenshot) and this works. Maybe I don't understand how the tREST component is supposed to work here but I am fine with this workaround.
Here is the bigger problem...
Now I want to iterate on the list that is returned from this step. So I built another job that reads the list from a file and sets a context variable that retrieves the second level data.
When I run this job I am getting the following error message..
Exception in component tREST_1
java.lang.IllegalArgumentException: Illegal character in query at index 158: http://www.mongoosemetrics.com/api/api.php?function=list_campaign_info&api_key=12345&campaign_code=9...
at java.net.URI.create(Unknown Source)
at com.sun.jersey.api.client.Client.resource(Client.java:402)
at cnsr_dw_new.mongoose_campaigns_0_1.mongoose_campaigns.tFileInputFullRow_1Process(mongoose_campaigns.java:1454)
at cnsr_dw_new.mongoose_campaigns_0_1.mongoose_campaigns.runJobInTOS(mongoose_campaigns.java:2190)
at cnsr_dw_new.mongoose_campaigns_0_1.mongoose_campaigns.main(mongoose_campaigns.java:2049)
Caused by: java.net.URISyntaxException: Illegal character in query at index 158: http://www.mongoosemetrics.com/api/api.php?function=list_campaign_info&api_key=982799e4e5cbad333a777...
at java.net.URI$Parser.fail(Unknown Source)
at java.net.URI$Parser.checkChars(Unknown Source)
at java.net.URI$Parser.parseHierarchical(Unknown Source)
at java.net.URI$Parser.parse(Unknown Source)
at java.net.URI.<init>(Unknown Source)
If I plug the generated URL (the second and third lines of the error message) into a browser it returns the proper data. So my method generates the proper URL but there is something that Talend doesn't like. This seems to me like an escape sequence or character issue but I have tried lots of combinations of these and had no luck.
Any help would be greatly appreciated...

Accepted Solutions
One Star

Re: [resolved] [R] Uing tRt t acc API

The problem was replacing spaces...
If I do this....
StringHandling.CHANGE("http://www.mongoosemetrics.com/api/api.php?function=caller_info&api_key=12345&campaign_code=" +((String)globalMap.get("out.campaign_code")) + "&start_timestamp=2010-01-01&end_timestamp=2014-03-31"," ","%20")
Then it works. Thank you Stack Overflow.

All Replies
One Star

Re: [resolved] [R] Uing tRt t acc API

The problem was replacing spaces...
If I do this....
StringHandling.CHANGE("http://www.mongoosemetrics.com/api/api.php?function=caller_info&api_key=12345&campaign_code=" +((String)globalMap.get("out.campaign_code")) + "&start_timestamp=2010-01-01&end_timestamp=2014-03-31"," ","%20")
Then it works. Thank you Stack Overflow.

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

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