cancel
Showing results for 
Search instead for 
Did you mean: 

Escaped quotes turning into not-escaped quotes and \n being turned into newline (HTTP to GraphQL)

bedelman0731
Deputy Chef II
Deputy Chef II

I'm building a pipeline that takes contents from one system (via an API call using the HTTP connector) which is then being used to create/update an object in a different system (via the GraphQL connector issuing a mutation). The content coming from the source system, at times, can contain embedded quotes in the content that are escaped (ex. \") - especially when that content is HTML based. Content that does not contain escaped quotes is working without issue.

Example of the incoming content: 

<p>Throughout this engaging session you will:</p>\n\n<ul>\n<li><span style=\"font-size:11pt\"><span style=\"font-family:Calibri,sans-serif\">Explore the transformative potential of leveraging low-code and no-code tools and workflows to automate repetitive and time-consuming office processes</span></span></li>\n<li><span style=\"font-size:11pt\"><span style=\"font-family:Calibri,sans-serif\">Capture data that can be used to make informed decisions regarding resource allocation</span></span></li>\n<li><span style=\"font-size:11pt\"><span style=\"font-family:Calibri,sans-serif\">Identify areas where investing time and energy can be most impactful</span></span></li>\n</ul>

However, when it goes to use the content from that step in the recipe to use GraphQL, it appears that the escaped quotes are not being escaped - which, I think, is what is causing the GraphQL connector to have an error.

Example of the content being sent via GraphQL: 

<p>Throughout this engaging session you will:</p>

<ul>
<li><span style="font-size:11pt"><span style="font-family:Calibri,sans-serif">Explore the transformative potential of leveraging low-code and no-code tools and workflows to automate repetitive and time-consuming office processes</span></span></li>
<li><span style="font-size:11pt"><span style="font-family:Calibri,sans-serif">Capture data that can be used to make informed decisions regarding resource allocation</span></span></li>
<li><span style="font-size:11pt"><span style="font-family:Calibri,sans-serif">Identify areas where investing time and energy can be most impactful</span></span></li>
</ul>

If I use the content with the escaped quotes and the escaped newlines to issue the same call using GraphQL to the destination system using Postman, the operation succeeds without issue.

Is there anyway to change things so that the content remains as it was originally ingested?

1 ACCEPTED SOLUTION

bedelman0731
Deputy Chef II
Deputy Chef II

Thank you for the suggestions! The issue was two-fold in that the escaped quotes were being un-escaped and the \n (or \r) were being expanded into newline or carriage returns. The solution which is working is to perform two .gsub operations

  1. Replace \r\n or \n or \r with a <p />
  2. Replace plain embedded quotes with escaped quotes
DATA.gsub(/(\r\n|\n|\r)/,'<p />').gsub('"','\"')

 

View solution in original post

6 REPLIES 6

bedelman0731
Deputy Chef II
Deputy Chef II

Thank you for the suggestions! The issue was two-fold in that the escaped quotes were being un-escaped and the \n (or \r) were being expanded into newline or carriage returns. The solution which is working is to perform two .gsub operations

  1. Replace \r\n or \n or \r with a <p />
  2. Replace plain embedded quotes with escaped quotes
DATA.gsub(/(\r\n|\n|\r)/,'<p />').gsub('"','\"')

 

Hi @bedelman0731 ,

Great to hear that, Happy to help. 

Thanks and Regards,
Shivakumara K A