PASS XML content within the JSON request in \Web-Request\" Action Office 365."

  • 29 August 2017
  • 1 reply
  • 21 views

Badge +5

Hello Community,

 

I am using "Web-Request" Action, to initiate a REST query of type "applicationjson".

 

In the Body section, I need to PASS XML content within the JSON request. What is the best way to do it?

 

My Final JSON should look like this

 

{

  "sharepoint_file": {

    "site_url": "https://test.sharepoint.com/sites/monday2/",

    "source_file_url": "/sites/monday2/WMWebservice/1.pdf",

    "destination_file_url": "/sites/monday2/WMWebservice/1.pdf",

  },

  "watermark_data": "

 <watermark

    hPosition="Center"

    vPosition="Bottom"

    width="300"

    height="300"

    zOrder="1"

    rotation="0"

    opacity="100"

    pageOrientation="both">

    <text

      width="200"

      height="200"

      fillColor="red"

      content="Your content goes here"

      fontFamilyName="Times New Roman"

      fontSize="12"

      fontStyle="bold|italic"

      wordWrap="word"

   />"

}

If, I pass the JSON as it the web-service as it is, it does not work. It seems that Nintex does not like "white spaces" in the XML/JSON. Removing with spaces in XML can be tricky.

 

I got to know that we have a BUG in Nintex and also discovered workaround for passing JSON in webservice action. https://community.nintex.com/thread/13842-build-string-json-and-workflow-variables-not-working.

 

However, now I need to PASS XML with a JSON and I need to understand the best way to move forward.

 

Note: Normal REST query with JSON works fine, If I use an external client like ARC(https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo)  the REST query completes with the above JSON.nintexworkflows office365#web-request


1 reply

Badge +2

I don't think this is a Nintex Workflow specific question, you need to escape your (XML) quotation marks when you embed it in a string. Try putting a backslash in front of each.

So 

...

"watermark_data": "

 <watermark

    hPosition=""Center""

    vPosition=""Bottom""

...

You also have an extra comma before the ‘}’, which is not valid.

Then there is the issue of line breaks in the middle of your xml, you can’t just open a string (“) and then put line breaks in them

Have a look at online JSON validators before even trying to pass it into Nintex.

Reply