cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RTW
Advocate II
Advocate II

XPATH returns null

Hi all. I'm trying to automate some tasks with Tableau. Basically the flow is:

 

  1. Logon request to Tableau Server via HTTPS
  2. Extract token
  3. Pass tokens into other HTTPS requests
  4. ???
  5. Profit

I got pretty much everything worked out and working but I really don't like how I get the token out. Currently I'm using a convoluted mix of Search() and Substring() to extract it. I would love to use XPATH as its a lot easier to implement and I'm always game to learn new things.

 

Here is the XML data that is returned by the logon request:

 

 

 

<?xml version='1.0' encoding='UTF-8'?>
<tsResponse xmlns="http://tableau.com/api" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tableau.com/api http://tableau.com/api/ts-api-3.6.xsd">
    <credentials token="THIS IS TOKEN">
        <site id="THIS IS SITE" contentUrl=""/>
        <user id="THIS IS USERID"/>
    </credentials>
</tsResponse>

 

 


From this I would like to extract the following string "THIS IS TOKEN" using XPATH. I used this tool to test the XPATH expression and this seems to work "string(/tsResponse/credentials/@token)"

 

The issue is running it into flow. Initially I was using the HTTP request action but I didn't want to make too many requests so I created a mockup where I paste a sample payload into a Compose action and have a second compose action that executes the XPATH.

 

This is the expression I use on the second Compose action where "Compose 2" has the text"

 

 

 

xpath(xml(outputs('Compose_2')),'string(/tsResponse/credentials/@token)')

 

 

Here is the result of the flow.

 

image.png

 

I've tired a few other XPATH examples from online and they seem to work but I just can't get this to function correctly. Any idea what I am doing wrong?

1 ACCEPTED SOLUTION

Accepted Solutions
abm
Super User III
Super User III

Try the following:

 

xpath(xml(outputs('Compose_2')),'//*[local-name()="credentials"]/@token')


Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

View solution in original post

4 REPLIES 4
abm
Super User III
Super User III

Try the following:

 

xpath(xml(outputs('Compose_2')),'//*[local-name()="credentials"]/@token')


Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

View solution in original post

v-bacao-msft
Community Support
Community Support

 

Hi @RTW ,

 

Please try to refer to the following method to configure Flow:

xPath-parsing-noob

XML-convert-to-other-XML-format

 

In addition, you can follow the link and get more details about the XPath() function:

https://docs.microsoft.com/en-gb/azure/logic-apps/workflow-definition-language-functions-reference#x...

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
RTW
Advocate II
Advocate II

@abm Thank you, this worked.

 

I had to modify it slightly to xpath(xml(outputs('Compose_2')),'string(//*[local-name()="credentials"]/@token)') to get the correct output.

 

So, that being said, what did I do wrong?

abm
Super User III
Super User III

Hi @RTW 

 

XPath queries are not the straight forward ones. Glad to hear that it is working.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors
Users online (1,184)