Issue in geting URL from array in AJO journey
Hi All,
I am trying to create a journey where i pull data from an API end poing using AJO custom actions. and there is a filed in the response called as id. the id is stored in an array like this:
{
"data": {
"multiContextList": {
"items": [
{
"DisplayDate": "dateOnly",
"publisheddate": "dateTime",
"pageUrl": "string",
"_id": "string"
}
]
}
}
}
I want to use this ID to create a URL in the AJO journey email like this: https://domain/_ID.
But when i pull the data suing the action all the fields can be printed in the email body using the script:
{{#each context.journey.actions.413214ba-8a6c-4564-8a97-88585292066e.data.multiContextList.items as |items|}}{%#if @index = 0%}{{items._id}}{%/if%}{{/each}}
but its not getting populated in the URL part of the email. It shows an error in the journey: Invalid value for the parameter originalUrl found at Position(274,1152) in url helper. (CJMTL - 010030-422).
Also, I am also not able to create a variable in the HTML script using the same code.
{% let authURL = concat("https://my-url/",{{#each context.journey.actions.413214ba-8a6c-4564-8a97-88585292066e.data.multiContextList.items as |items|}}{%#if @index = 0%}{{items._id}}{%/if%}{{/each}}) %}
It gives an error: Invalid syntax found: '{%/', expected: 'EOF'. Error beginning at position: Line 253, Character 207.
Also if I use the attribute in URL parameter like this:
https://my-url/{{context.journey.actions.413214ba-8a6c-4564-8a97-88585292066e.data.multiContextList.items.0._id}} or https://my-url/{{context.journey.actions.413214ba-8a6c-4564-8a97-88585292066e.data.multiContextList.items.[0]._id}} it thrown an error: context.journey.actions.413214ba-8a6c-4564-8a97-88585292066e.data.multiContextList.items.0._id not found. Error beginning at position: Line 1, Character 45.
I cant use head function as I not only have to get the 0th value but all the _id values at all locations.
BTW if i use the code: {{#each context.journey.actions.413214ba-8a6c-4564-8a97-88585292066e.data.multiContextList.items as |items|}}{%#if @index = 0%}{{items._id}}{%/if%}{{/each}} or {{#each context.journey.actions.413214ba-8a6c-4564-8a97-88585292066e.data.multiContextList.items as |items|}}{%#if @index = 1%}{{items._id}}{%/if%}{{/each}} and so on, i see the respective values.
Has someone faced this kind of issue. Any help would be appreciated.
Thanks,
Mohit