Forum Discussion

Andrevz's avatar
Andrevz
Copper Contributor
Apr 19, 2020

Logic Apps xpath expression issue

I get an XML response from an HTTP call and then need to find a value to be used to set another variable value to be used in another HTTP call.

 

I managed to get the following expression to work which finds an element containing a certain string and then return the value of a preceding sibling. Here is the expression: 

"xpath(xml(string(body('HTTP'))),'string(/*[name()="ns2:return"]/*[name()="ns2:workspaces"]/*[name()="ns2:workspace"]/*[name()="projectName" and contains(., "avz Test WorkSpace")]/preceding-sibling::id)')"

 

However I am trying to make the highlighted search value dynamic - i.e. I get the value from the original input file name (using substring expression) and set a STRING variable called WorkSpaceName. Again tested this and value is set correctly.

 

However here is the issue: I change the expression as follows (replacing the string "avz Test Wrokspace" with the valiable i.e. variables('WorkSpaceName')

"....... and contains(., variables('WorkSpaceName'))]/...." Everything else I leave the same and would expect to return the same value. When I try to update the expression in Logic App I get an error saying "The expression is invalid.". Seems it does not like the use of a variable in this expression or it is expecting a different representation of the variable expression here. Tried many different approaches - also tried to directly use the substring extression here to get the value from the fileName and also get the same error. When I return the hardcoded string then it works.

 

Would appreciate it if anyone has any advice that may help resolve this issue.

 

Thanks

 

Andre

  • Andrevz's avatar
    Andrevz
    Copper Contributor

    Opened support ticket with Microsoft as no-one seems to know how to resolve this issue. Case Ref Case 120042723000004.

     

    I will reply here with any responses from MS related to this issue.

Resources