web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to extract from XM...
Power Automate
Answered

How to extract from XML String Output of HTTP Request

(0) ShareShare
ReportReport
Posted on by

Hello everyone,

 

I need to create Change Tasks in ServiceNow via PowerAutomate and am using HTTP Requests to do that. I then need to get the CTASK ID from the Body output of the HTTP Request so that I can update and close the Ctasks in a later step during the release of the software. I have trimmed down the flow to try to just get the id and cannot find a combination to make it work.

 

I can do a compose on the Body of the HTTP Request and get the following: 

<id>CTASK0257585</id><key>GUID_ID_HERE</key>

I then try to do a compose to get just the ID. I have used outputs('compose')?['body']['id'] or body('compose')?['id'] and variations of this with create_ctask and numerous other ideas from the forums and at best I get the click to download which is blank or will get an error saying the id isn't in the body. Any help would be appreciated!

I have also tried parsing a json but the format is xml so won't render into the json to extract the <id>.
 
 Screenshot 2024-01-30 at 10.16.40 AM.png
Categories:
I have the same question (0)
  • wskinnermctc Profile Picture
    6,519 Moderator on at

    You could try getting the data out of the string using something like xpath(xml(<add string here>),...) that you can read about in Manual T Gomes XPath Function which shows some examples. Just note that his primary example is showing an XML document, where it seems like you are using a string, so you will need to scroll down to the section Common Mistakes and Solutions.

     

    There is also a video about Working with XML in Power Automate by @DeepakS which is also showing XML from file content. But it might help give you an idea.

     

    You could also try changing the topic of your forum post from "Get ID from Http Request - Click to Download" to something like "How to extract from XML String Output of HTTP Request" which might make it easier for people to recognize if they know a solution.

     

    I don't know much about it, but you could look into the functions xml() or xpath() which deal with converting this type of data. I also think there is a way to use json() or parse json action along with xml() and it get things separated.

    Maybe give a direction to search for help.

  • Verified answer
    harshdeol Profile Picture
    619 Super User 2026 Season 1 on at

    Hi @dscull ,

    The goal is to extract the id from XML, Right? Please try below expressions:

    //XML:

    <root>
     <id>CTASK0257585</id>
     <key>GUID_ID_HERE</key>
    </root>

    //Flow Actions and expressions:

    harshdeol_1-1706640988017.png

    //For id:

    join(xpath(xml(outputs('Compose')),'//id/text()'),',')

    //For key:

    join(xpath(xml(outputs('Compose')),'//key/text()'),',')

     

    //Output:

    harshdeol_0-1706640836342.png

     

    -------------------------------------------------------------------------------------------------------------------------
    If your question got an answer, please click "Accept as Solution "✅, If you liked my answer, please hit the "thumbs-up" 👍button.

    Thank you,
    Harsh Deol

  • dscull Profile Picture
    on at

    Thanks @wskinnermctc - I tried running 10 more tests using the documents / video for help you provided and just ran into more errors. Can't parse XML file for the XPATH stuff, that wasn't covered in the common questions document. XML file won't port into the JSON to be formatted per the video tutorial. 

    Seems odd I just need to extract the id from the output of the HTTP Response so I can use it in another HTTP Response to update the correct object in ServiceNow, but I can't get that ID to show up. Any other ideas are welcome.

     

    Screenshot 2024-01-30 at 12.18.40 PM.png

  • dscull Profile Picture
    on at

    @harshdeol If I define the xml in the compose like in your example that works. How do I do that automatically now?

    EDIT: If you do the compose as <root> HTTP BODY </root> it worked.

     

    Screenshot 2024-01-30 at 12.34.56 PM.png

     

    Thank you so much!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 573

#2
Valantis Profile Picture

Valantis 407

#3
11manish Profile Picture

11manish 387

Last 30 days Overall leaderboard