Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello ,
While generating token from RESTAPI , I get below response
serverURL = "https://tableau-sandbox.com"
credentialsToken = "AWHBsYtEQ2OiIJV2tqdasdasOGH2aSD44zbgaHWztlVLe7plIFES4"
siteId = "07aqwe5422e135-4b6b2234-099be525871c"
siteContentUrl = "Talend"
userId = "32aa851d-fb20-49b3-8eed-7f83c406f85a"
userName = "TALEND_TALEND"
This is not XML/JSON , looks like non-standard format, how can we extract token information using talend job ?
Okay , so I tried to convert it to JSON file, but there were more obstacles than just simply replacing = with :
I did proceed with making it JSON , not very efficient , but I used below code in tjavarow and then extracted the fields using tjsonextract
context.response = input_row.ResponseContent;
context.response = context.response.replaceAll("=",":");
context.response = context.response.replaceAll("# REST API session created by Tableau Assist","");
context.response = context.response.replaceAll("serverURL","\"serverURL\"");
context.response = context.response.replaceAll("credentialsToken","\"credentialsToken\"");
context.response = context.response.replaceAll("siteId","\"siteId\"");
context.response = context.response.replaceAll("siteContentUrl","\"siteContentUrl\"");
context.response = context.response.replaceAll("userId","\"userId\"");
context.response = context.response.replaceAll("userName","\"userName\"");
context.response = context.response.replaceAll("\"\n","\",");
context.response = "{ " + context.response + " }";
@karan dama , if you have : instead of = then replace = with : by reading all json file.
Thanks,
Manohar
Hi ,
Try with tExtractDelimited component
Thanks
Jilani Syed
I think you could store the required information in global variable using java components, then you can pass it to next component.
Please let me know if it helps
Okay , so I tried to convert it to JSON file, but there were more obstacles than just simply replacing = with :
I did proceed with making it JSON , not very efficient , but I used below code in tjavarow and then extracted the fields using tjsonextract
context.response = input_row.ResponseContent;
context.response = context.response.replaceAll("=",":");
context.response = context.response.replaceAll("# REST API session created by Tableau Assist","");
context.response = context.response.replaceAll("serverURL","\"serverURL\"");
context.response = context.response.replaceAll("credentialsToken","\"credentialsToken\"");
context.response = context.response.replaceAll("siteId","\"siteId\"");
context.response = context.response.replaceAll("siteContentUrl","\"siteContentUrl\"");
context.response = context.response.replaceAll("userId","\"userId\"");
context.response = context.response.replaceAll("userName","\"userName\"");
context.response = context.response.replaceAll("\"\n","\",");
context.response = "{ " + context.response + " }";