I am extracting href from a link to get the url for pagination, i am storing an api response in blob as json. Using lookup activity i am reading the json and set a variable for next pagination url. The below logic is working fine when file has a pagination and url is in a link array. But when there is no pagination url present in a file then link is not an array and i am getting this error
expression cannot be evaluated because property 1 cannot be selected object. properties can only be selected by names
Logic
@if(
equals (activity('LookupActivity').output. firstRow[ 'feed']
['link '][1]['@rel'], 'next'),
activity('LookupActivity').output.firstRow['feed ']['link'][1]
'@href'],
āā
)
Pagination-
No pagination
I am using this variable in until activity and iterating through other pages.
You are receiving the above error when there is no pagination. It's because in this case, the link
key value is a JSON object unlike an array in the case of pagination.
So, first check whether the link
value is object or an array and then check your condition. Modify your expression like below.
@if(
and(and(contains(string(activity('Lookup1').output.firstRow['feed']['link']),'['),greaterOrEquals(length(activity('Lookup1').output.firstRow['feed']['link']),1)),equals(activity('Lookup1').output.firstRow['feed']['link'][1]['@rel'], 'next')),activity('Lookup1').output.firstRow['feed']['link'][1]['@href'],''
)
Now, it will give expected results in both cases of pagination and no pagination.
Result with Pagination:
Result when there is no Pagination: