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:
@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.
Thank you so much!
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.
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:
//For id:
join(xpath(xml(outputs('Compose')),'//id/text()'),',')
//For key:
join(xpath(xml(outputs('Compose')),'//key/text()'),',')
//Output:
-------------------------------------------------------------------------------------------------------------------------
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
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.
WarrenBelz
146,660
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,999
Most Valuable Professional