Remote Json with Variable URL

Hello,

I have a Print job that requires me to pickup a Remote Json Value. I’m able to retrieve the information I need when I insert an exact URL when creating the .rjson snippet. I use a simple script from the documentation to load it and it works fine. However, I need to take this 1 step further and make the URL Variable. For example, a static URL I need is : https://svc.anycompany.ca/paragraphservice/api/paragraph/**12345-6789**/en/firstperson
But what I want to do is make the bolded part variable from the data file. So the variable URL would actually be something like this: “https://svc.anycompany.ca/paragraphservice/api/paragraph/+ custid + “/en/firstperson”

I could even build the URL string outside of PresConnect then bring the entire string in as it’s own variable field. But how would I be able to use the URL in the rjson snippet if I have to enter a URL?

Worst case scenario is I write another work around to create the entire customer paragraph outside of PresConnect and then add it as a data field in the data file. This is not desirable though and a last resort.

Thank you,

You could use the loadjson() from a script in your Template. This way you can make it as dynamic as you want.

Thank you…this worked. I thought the loadjson() needed to reference an rjson snippet, but it doesn’t.
I did the following:

var json_data = loadjson(“https://svc.anycompany.ca/paragraphservice/api/paragraph/” + record.fields[“field1”] + “/en/last”);
results.html(json_data.text_to_use);

Thanks for the help!

1 Like