Forum Discussion

yashasvi74's avatar
yashasvi74
New Contributor
4 years ago
Solved

Posting xml to webservice through rest post snap

Hi ALL,

There’s a requirement where need to post a xml to a webservice using REST POST snap but its not working instead giving error (cannot use SOAP execute snap).
But when trying to post the same xml using postman its working.
It would be great if someone can help.

  • Hi @darshthakkar,

    One approach will be to Map the input document with the following expression:

    $.entries().sort((a,b) => a[0].localeCompare(b[0])).reduce((acc,curr) => acc.extend({[curr[0]]:curr[1]}),{})
    

    Note: This will only sort properties on first level.

    Let me know if this helps.

    BR,
    Aleksandar.

  • As we cannot mark multiple suggestions as “Solutions”, wanted to summarize the solution that will work for this use case:

    1. $.entries().sort((a,b) => a[0].localeCompare(b[0])).reduce((acc,curr) => acc.extend({[curr[0]]:curr[1]}),{})

    2. $.keys().sort().toObject((k,i)=> k, (k,i)=> $.get(k))

    Both the expressions mentioned above will ONLY work if we are at the last stage of the hierarchy.

    How I broke the hierarchy: Using JSON Splitter to reorganise JSON - #3 by Supratim

    Thank you @AleksandarAngelevski , @alchemiz and @Supratim for your inputs. Closing this thread now.

7 Replies