I have the expression below for an HTTP lookup (an OData lookup using the connector for Microsoft Dynamics 365/CRM).
/api/data/v8.2/accounts?$filter=emailaddress1 eq '{{{encodeURI data.billing_email}}}' and name eq '{{{encodeURI (replace data.billing_firstname "'" "''")}}}%20{{{encodeURI (replace data.billing_lastname "'" "''")}}}' and statecode eq 0
I need to replace all single quotes in the name fields with 2 single quotes, and encode all 3 fields for a URI. When I preview it, everything looks fine. When I run it, I get the error below.
The field ""''"), "''")" was not found in the source data. https://{{{connection.settings.microsoftDynamics365Subdomain}}}.dynamics.com/api/data/v8.2/accounts?$filter=emailaddress1 eq '{{{encodeURI data.billing_email}}}' and name eq '{{{encodeURI (replace data.billing_firstname "'" "''")}}}%20{{{encodeURI (replace data.billing_lastname "'" "''")}}}' and statecode eq 0
It seems to not evaluate the single quote(s) within the double quotes as string literals.
I'd suggest making a support ticket in this case so we can troubleshoot some more. I'm out of ideas since I was able to get it to work for me, albeit with a dummy API endpoint since I don't have access to D365.
I guess to unblock yourself, maybe you could put a transformation before this step to replace it ahead of time?
Thanks Tyler! I moved the replace to a new field added in the transformation, and kept
rest of the handlebar expression (with encodeURI) on the lookup. That worked fine.
I will submit this to support when I have the chance.