How to get id field from http xml response in power automate
<?xml version="1.0" encoding="UTF-8"?>
<ServiceResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://test.qg.apps.test.com/qps/xsd/3.0/was/report.xsd">
<responseCode>SUCCESS</responseCode>
<count>1</count>
<data>
<Report>
<id>3505012</id>
</Report>
</data>
</ServiceResponse>
how can i get outcome 3505012 in result
tried below
#{slice(outputs('createreportxml'), add(nthIndexOf(outputs('createreportxml'), '>', 9), 1), nthIndexOf(outputs('createreportxml'), '<', 10))}
as well as below
xpath(xml(outputs('#{outputs('createreportxml')}'))), 'string(/ServiceResponse/data/Report/id/text())'
sample flow
Got it working with below has small issue with one braces.
#{xpath(xml(outputs('createreportxml')),'string(/ServiceResponse/data/Report/id/text())')}
Related
we need to read a xml file in sql server but we are having problems because the xml have a namespace, I have tried several solutions but I can't resolve the problem.
the xml file looks like this
<?xml version="1.0" encoding="UTF-8"?>
<Status:orders xmlns:Status="http://www.test.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.test.com Status.xsd">
<order>
<Header>
<Name>500039</Name>
<Letter>A</Letter>
</Header>
</order>
</Status:orders>
can you help how to retrieve the values for the Name and letter tags
thanks in advance.
Your friend is called WITH XMLNAMESPACES...
Try it like this
DECLARE #xml XML=
'<?xml version="1.0" encoding="UTF-8"?>
<Status:orders xmlns:Status="http://www.test.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.test.com Status.xsd">
<order>
<Header>
<Name>500039</Name>
<Letter>A</Letter>
</Header>
</order>
</Status:orders>';
WITH XMLNAMESPACES('http://www.test.com' AS Status)
SELECT #xml.value('(/Status:orders/order/Header/Name)[1]','int')
,#xml.value('(/Status:orders/order/Header/Letter)[1]','varchar(max)');
An alternative was, to use the asterisk.
SELECT #xml.value('(/*:orders/order/Header/Name)[1]','int')
,#xml.value('(/*:orders/order/Header/Letter)[1]','varchar(max)');
Another alternative was this:
SELECT #xml.value('(//Name)[1]','int')
,#xml.value('(//Letter)[1]','varchar(max)');
But in general it is good advice, to be as specific as possible...
I'm currently implementing a WCF Client app which consumes a Java webservice that uses SOAP as the communication protocol. I generated a proxy from the WSDL provided by the server and when I make calls everything runs through without an error but the received list contains no elements.
I've looked at the incoming XML with Wireshark and WCF tracing/message logging and therefore can be certain that I do receive the intended data. But it seams that the WCF Client somehow manipulates the XML before parsing by inserting an empty namespace which prevents the deserializer from creating the objects from the xml.
Wireshark
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header/>
<SOAP-ENV:Body xmlns:ns="stat">
<ns:mt_getStation>
<ROW>
<Station_ID>96</Station_ID>
<Station>Station Test</Station>
<Timestamp>2014-09-15T14:00:35</Timestamp>
</ROW>
<ROW>
<Station_ID>42</Station_ID>
<Station>Answer Station Test</Station>
<Timestamp>2014-09-15T14:00:35</Timestamp>
</ROW>
</ns:mt_getStation>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
WCF Message log
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Header></SOAP-ENV:Header>
<SOAP-ENV:Body xmlns:ns="stat">
<ns:mt_getStation>
<ROW xmlns="">
<Station_ID>96</Station_ID>
<Station>Station Test</Station>
<Timestamp>2014-09-15T14:00:35</Timestamp>
</ROW>
<ROW xmlns="">
<Station_ID>42</Station_ID>
<Station>Answer Station Test</Station>
<Timestamp>2014-09-15T14:00:35</Timestamp>
</ROW>
</ns:mt_getStation>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
How can I prevent the WCF client from inserting the empty namespaces?
I create an XML document using the below code
For Each cust As Customer In Customers
XDoc = <?xml version="1.0" encoding="UTF-16" standalone="yes"?>
<Customers>
<Customer>
<Name>Mike</Name>
<Age>0</Age>
</Customer>
</Customers>
Next
XDoc.Save("C:\myXmlfile.xml")
However it only seems to add one record, but i dont know how to readd the nodes for each record? So if theres 2 records then i would expect
<?xml version="1.0" encoding="UTF-16" standalone="yes"?>
<Customer>
<Name>Mike</Name>
<Age>0</Age>
</Customer>
<Customer>
<Name>Mike</Name>
<Age>0</Age>
</Customer>
but it should only generate one xml file.
Could anyone guide me in what i need to do please? Even after searching around im not 100% sure as theres too many methods and ive probably got confused.
Thanks
Inside the loop you set XDoc to the the customer. This means that when you save XDOC ONLY the last customer will be saved.
Even if you fix the above, you still have the issue that you are trying to add multiple root elements (each customer) to the XML document. This is not allowed, only one root element is allowed. So to produce a valid XML document, you want something like:
<Customers>
<Customer>
<Name>Mike</Name>
<Age>0</Age>
</Customer>
<Customer>
<Name>Mike</Name>
<Age>0</Age>
</Customer>
</Customers>
I'm sorry but I can recommend how to change your code, because I don't know the VB.Net extensions for XML. Hopefully, someone else will shed some light.
BTW, interesting handle.
You can generate XDocument and XElement separately.
Further, you can set data from variable using <%= %>.
Therefore, you should generate and combine like below.
' Generate customers
Dim customers As XEelement = <Customers></Customers>
For Each cust As Customer In Customers
customers.Add(
<Customer>
<Name><%= cust.Name %></Name>
<Age><%= cust.Age %></Age>
</Customer>
)
Next
' Combine customers
Dim XDoc As XDocument =
<?xml version="1.0" encoding="UTF-16" standalone="yes"?><%= customers %>
XDoc.Save("C:\myXmlfile.xml")
In addition to #RichardSchneider's answer, this is sample snippet in VB.
First, construct XDocument with single <Customers> element as root. Then in each iteration of For Each loop, add single <Customer> element to the root element of the XDocument :
XDoc As XDocument = <?xml version="1.0" encoding="UTF-16" standalone="yes"?><Customers></Customers>
For Each cust As Customer In customers
XDoc.Root.Add(
<Customer>
<Name>Mike</Name>
<Age>0</Age>
</Customer>
)
Next
XDoc.Save("C:\myXmlfile.xml")
I'm getting the following error (see Response) while attempting to register a user. The code was working fine before but it seems something changed.
Request:
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:ns3="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns0="http://userregistration.usermanagement.core.soap.yodlee.com"
xmlns:ns1="http://common.soap.yodlee.com"
xmlns:ns2="http://login.ext.soap.yodlee.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<ns3:Body>
<ns0:register3>
<cobrandContext xsi:type="ns1:CobrandContext">
<cobrandId>8910005960</cobrandId>
<channelId>-1</channelId>
<locale>
<country>US</country>
<language>en</language>
</locale>
<tncVersion>2</tncVersion>
<applicationId>58EEA306454D869DFF721D0D00B82D00</applicationId>
<cobrandConversationCredentials xsi:type="ns2:SessionCredentials">
<sessionToken>05292013_0:718a0b8d870c13b5be2d2fb14bfd53b3796c5c97b401d68d34fe4594fdefeab3a3e5d6d8ee14696a6e03f53f0da613b781f1be0c8c06e70b883bb9abe232ba9f</sessionToken>
</cobrandConversationCredentials>
<preferenceInfo>
<currencyCode>USD</currencyCode>
<timeZone>PST</timeZone>
<dateFormat>MM/dd/yyyy</dateFormat>
<currencyNotationType>SYMBOL_NOTATION</currencyNotationType>
<numberFormat>
<decimalSeparator>.</decimalSeparator>
<groupingSeparator>,</groupingSeparator>
<groupPattern>###,##0.##</groupPattern>
</numberFormat>
</preferenceInfo>
<currencyCode>USD</currencyCode>
<timeZone>PST</timeZone>
<dateFormat>MM/dd/yyyy</dateFormat>
<currencyNotationType>SYMBOL_NOTATION</currencyNotationType>
<numberFormat>
<decimalSeparator>.</decimalSeparator>
<groupingSeparator>,</groupingSeparator>
<groupPattern>###,##0.##</groupPattern>
</numberFormat>
</preferenceInfo>
<fetchAllLocaleData>false</fetchAllLocaleData>
</cobrandContext>
<userCredentials xsi:type="ns2:PasswordCredentials">
<loginName>someyodleeuser#somedomain.com</loginName>
<password>yodleepasswordtest</password>
</userCredentials>
<userProfile>
<values>
<table>
<key xsi:type="xsd:string">EMAIL_ADDRESS</key>
<value xsi:type="xsd:string">someyodleeuser#somedomain.com</value>
</table>
</values>
</userProfile>
</ns0:register3>
</ns3:Body>
</SOAP-ENV:Envelope>
Response:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server</faultcode>
<faultstring>IllegalArgumentValueExceptionFaultMessage</faultstring>
<detail>
<ns4:IllegalArgumentValueExceptionFault xmlns:ns4="http://core.soap.yodlee.com">
<faultText>com.yodlee.core.IllegalArgumentValueException: Multiple exceptions encapsulated within: invoke getWrappedExceptions for details</faultText>
</ns4:IllegalArgumentValueExceptionFault>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
Problem is, I'm not getting back any details on the exception to debug the issue (Even when doing as suggested).
Your password is not in the right format and hence you are getting this error.
Below are the restrictions on username and password which you should follow -
UserName
>= 3 characters <= 150 characters
pNo Whitespace
No Control Characters
Contains at least one Letter
Password
>= 6 characters
<= 50 characters
No Whitespace
No Control Characters
Contains at least one Number
Contains at least one Letter
Does not contain the same letter/number three or more times in a row. (e.g. aaa123 would fail for three \"a\"'s in a row, but a1a2a3 would pass)"); Does not equal username
I have placed test orders in the sandbox eBay account.
I am not able to get the orders listing from the GetOrders API call.
It retruns the success message but no orders are fetched.
Below are the API call details :
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns="urn:ebay:apis:eBLBaseComponents" ><soap:Header><RequesterCredentials><eBayAuthToken>...</eBayAuthToken><Credentials><AppId>Clarion89-2b36-4da6-b073-00dafbcff12</AppId><DevId>f79169c1-f95b-4d23-9fe2-547504ffb827</DevId><AuthCert>...</AuthCert></Credentials></RequesterCredentials></soap:Header><soap:Body><GetOrdersRequest><DetailLevel>ReturnAll</DetailLevel><Version>527</Version><CreateTimeFrom>2012-04-02T09:52:27.000Z</CreateTimeFrom><CreateTimeTo>2012-05-03T09:52:27.000Z</CreateTimeTo><OrderRole>Seller</OrderRole><OrderStatus>Active</OrderStatus><ListingType>FixedPriceItem</ListingType></GetOrdersRequest></soap:Body></soap:Envelope>
Response returned as below
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<GetOrdersResponse xmlns="urn:ebay:apis:eBLBaseComponents">
<Timestamp>2012-05-03T09:54:03.650Z</Timestamp>
<Ack>Success</Ack>
<Version>771</Version>
<Build>E771_CORE_BUNDLED_14795207_R1</Build>
<PaginationResult>
<TotalNumberOfPages>0</TotalNumberOfPages>
<TotalNumberOfEntries>0</TotalNumberOfEntries>
</PaginationResult>
<HasMoreOrders>false</HasMoreOrders>
<OrderArray/>
<OrdersPerPage>100</OrdersPerPage>
<PageNumber>1</PageNumber>
<ReturnedOrderCountActual>0</ReturnedOrderCountActual>
</GetOrdersResponse>
</soapenv:Body>
</soapenv:Envelope>
Please tell me why i am not getting order details
first of all i would use an higher version (i'm actually using 771 as compatibility level)
I used to have a similar problem at the very benning when i started coded for api, then i switched CreatedTime filter to NumberOfDays wich are the days to look back from today.
What language are you using to make the call?
Check your request parameters against your orders that are stored on ebay. It may happen that there are no orders matching the parameters you are entering in your call. Try entering the most basic request parameters like
<?xml version="1.0" encoding="utf-8"?>
<GetOrdersRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>[your authentication token]</eBayAuthToken>
</RequesterCredentials>
<CreateTimeFrom>2012-05-10T00:00:00.000Z</CreateTimeFrom>
<CreateTimeTo>2012-05-15T00:00:00.000Z</CreateTimeTo>
</GetOrdersRequest>
You can enter the dates as per your requirement but make sure you use the date format accepted by ebay.