Error evaluating handlebar expression for HTTP lookup

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.

When you enable debug logs on the lookup, can you see what it's sending? I tested this using field settings and it seems to be sending fine.

/v1/mirror?$filter=emailaddress1 eq '{{{encodeURI settings.export.billing_email}}}' and name eq '{{{encodeURI (replace settings.export.billing_firstname "'" "''")}}}%20{{{encodeURI (replace settings.export.billing_lastname "'" "''")}}}' and statecode eq 0
{
  "billing_email": "tyler.lamparter@celigo.com",
  "billing_firstname": "tyler's",
  "billing_lastname": "lamparter's"
}

The debug log doesn’t even show an attempt to do the HTTP GET. It seems to be an error from Celigo during expression evaluation.

That is odd. If you reference record. instead of data., does it change the outcome?

The error is the same.

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.

2 Likes