Logic Apps xpath expression issue

%3CLINGO-SUB%20id%3D%22lingo-sub-1318856%22%20slang%3D%22en-US%22%3ELogic%20Apps%20xpath%20expression%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1318856%22%20slang%3D%22en-US%22%3E%3CP%3EI%20get%20an%20XML%20response%20from%20an%20HTTP%20call%20and%20then%20need%20to%20find%20a%20value%20to%20be%20used%20to%20set%20another%20variable%20value%20to%20be%20used%20in%20another%20HTTP%20call.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20managed%20to%20get%20the%20following%20expression%20to%20work%20which%20finds%20an%20element%20containing%20a%20certain%20string%20and%20then%20return%20the%20value%20of%20a%20preceding%20sibling.%20Here%20is%20the%20expression%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%22%3CEM%3E%3CSTRONG%3Expath(xml(string(body('HTTP')))%2C'string(%2F*%5Bname()%3D%22ns2%3Areturn%22%5D%2F*%5Bname()%3D%22ns2%3Aworkspaces%22%5D%2F*%5Bname()%3D%22ns2%3Aworkspace%22%5D%2F*%5Bname()%3D%22projectName%22%20and%20contains(.%2C%20%22avz%20Test%20WorkSpace%22)%5D%2Fpreceding-sibling%3A%3Aid)')%3C%2FSTRONG%3E%3C%2FEM%3E%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%20I%20am%20trying%20to%20make%20the%20highlighted%20search%20value%20dynamic%20-%20i.e.%20I%20get%20the%20value%20from%20the%20original%20input%20file%20name%20(using%20substring%20expression)%20and%20set%20a%20STRING%20variable%20called%20WorkSpaceName.%20Again%20tested%20this%20and%20value%20is%20set%20correctly.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%20here%20is%20the%20issue%3A%20I%20change%20the%20expression%20as%20follows%20(replacing%20the%20string%20%22avz%20Test%20Wrokspace%22%20with%20the%20valiable%20i.e.%20variables('WorkSpaceName')%3C%2FP%3E%3CP%3E%22.......%26nbsp%3B%3CEM%3E%3CSTRONG%3Eand%20contains(.%2C%20variables('WorkSpaceName'))%5D%2F....%22%3C%2FSTRONG%3E%26nbsp%3BEverything%20else%20I%20leave%20the%20same%20and%20would%20expect%20to%20return%20the%20same%20value.%20When%20I%20try%20to%20update%20the%20expression%20in%20Logic%20App%20I%20get%20an%20error%20saying%20%22The%20expression%20is%20invalid.%22.%20Seems%20it%20does%20not%20like%20the%20use%20of%20a%20variable%20in%20this%20expression%20or%20it%20is%20expecting%20a%20different%20representation%20of%20the%20variable%20expression%20here.%20Tried%20many%20different%20approaches%20-%20also%20tried%20to%20directly%20use%20the%20substring%20extression%20here%20to%20get%20the%20value%20from%20the%20fileName%20and%20also%20get%20the%20same%20error.%20When%20I%20return%20the%20hardcoded%20string%20then%20it%20works.%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWould%20appreciate%20it%20if%20anyone%20has%20any%20advice%20that%20may%20help%20resolve%20this%20issue.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAndre%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1318856%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1339395%22%20slang%3D%22en-US%22%3ERe%3A%20Logic%20Apps%20xpath%20expression%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1339395%22%20slang%3D%22en-US%22%3E%3CP%3EOpened%20support%20ticket%20with%20Microsoft%20as%20no-one%20seems%20to%20know%20how%20to%20resolve%20this%20issue.%20Case%20Ref%20Case%20120042723000004.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20will%20reply%20here%20with%20any%20responses%20from%20MS%20related%20to%20this%20issue.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

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

1 Reply
Highlighted

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.