0

I have created a custom connector to connect to a SOAP XML API, and I am using the XML to Rest tool to create a full custom connector.

One of my API methods return a value that contains CDATA formatting, and when my Logic App is using the custom connector and returning this data, it stops at the CDATA and says "BadRequest. Http request failed: the content was not a valid JSON.".

Swagger editor in the custom connector has the property of this item as "type: string", but Logic Apps debugging comes up with the following error:

Parse error on line 1: <![CDATA[{"an ^ Expecting 'STRING', 'NUMBER',

Any help is appreciated!

1 Answers1

0

There is no CDATA in JSON. So the parser error is correct: that is not valid JSON.

You could try to encode the CDATA in a string literal using something like base64 encoding. For more information, see the answer (and comments!) to the question Binary Data in JSON String. Something better than Base64.

EDIT:
Since you created the custom connector, you are in control of how the XML is processed and 'converted' into JSON, right? This gives you the opportunity to

  • read the XML
  • convert the 'normal' data into valid JSON
  • encode the CDATA and add it to the JSON data
rickvdbosch
  • 14,105
  • 2
  • 40
  • 53
  • Thanks for the response. Unfortunately, I can't change what my vendor's API XML headers return, so I am stuck on the source side of things with plain XML and this one tag containing CDATA. On the processing side, I have not seen a way in Logic Apps to change the encoding of the XML coming back. I tried changing the format to be something else than normal JSON, but this caused errors in the Swagger editor. Have you done something like this in the past? – user14031004 Sep 14 '20 at 22:02
  • Sorry if I am not following this correctly, but in the Custom Connector properties of the action, I am able to edit the body payload in the response. It says "The payload that is available on the response. These are the tokens that will show up as the outputs in designer.". Editing my "value" tag in this response body editor, it shows as a String (which I knew), with no explicit format. I've tried changing the format to "html" and as "binary", save the connector, running the Logic App: the same error keeps coming up "BadRequest. Http request failed: the content was not a valid JSON.". – user14031004 Sep 15 '20 at 21:31