If I have the following XML:
<?xml version="1.0" encoding="utf-8"?>
<response>
<status>SUCCESS</status>
<result>
<message>
<field>
<name>referenceNumber</name>
<type>string</type>
<required>true</required>
<max>8</max>
<min>0</min>
<decimal_places>0</decimal_places>
</field> ...
Is there a way to get the value for response/result/message? I know I can use a find("message") but if there are more than 1 message node then it doesn't work. I would like to know if there is a way to get to a particular node without 'guessing' if you know what I mean.
Thanks
you want to use find().each('message)` http://api.jquery.com/jQuery.each/ kinda like
`$(xml).find("listing").each(function (){
// Do stuff.
});
Related
I am trying to create a Return Authorization from a Sales Order but can not determine the required parameters.
I keep receiving an error of:
You must enter at least one line item for this transaction.
If I attempt to include the id of one of the line items in the sales order I receive the following error:
Savon::SOAPFault ((soapenv:Server.userException)
com.netledger.util.schemabean.NLSchemaBeanException: id not found on
{urn:customers_2016_2.transactions.webservices.netsuite.com}
ReturnAuthorizationItem
This is my current request
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:platformMsgs="urn:messages_2016_2.platform.webservices.netsuite.com" xmlns:platformCore="urn:core_2016_2.platform.webservices.netsuite.com"
xmlns:platformCommon="urn:common_2016_2.platform.webservices.netsuite.com" xmlns:tranSales="urn:sales_2016_2.transactions.webservices.netsuite.com" xmlns:tranCust="urn:customers_2016_2.transactions.webservices.netsuite.com">
<env:Header>
<platformMsgs:tokenPassport>
<platformCore:account>1234_SB1</platformCore:account>
<platformCore:consumerKey>***FILTERED***</platformCore:consumerKey>
<platformCore:token>***FILTERED***</platformCore:token>
<platformCore:nonce>s975gqhodufgodiueroh</platformCore:nonce>
<platformCore:timestamp>1531918396</platformCore:timestamp>
<platformCore:signature algorithm="HMAC-SHA256">p0z56JDUsN+ksjhfe8HEhdEU(WJff7u+0Yee7Axk=
</platformCore:signature>
</platformMsgs:tokenPassport>
<platformMsgs:preferences>
<platformMsgs:ignoreReadOnlyFields>true</platformMsgs:ignoreReadOnlyFields>
</platformMsgs:preferences>
</env:Header>
<env:Body>
<platformMsgs:add>
<platformMsgs:record xsi:type="tranCust:ReturnAuthorization">
<tranCust:entity internalId="173436">
<platformCore:name>C030420 John Thomas</platformCore:name>
</tranCust:entity>
<tranCust:itemList>
<tranCust:item>
<tranCust:id>21354</tranCust:id>
</tranCust:item>
</tranCust:itemList>
</platformMsgs:record>
</platformMsgs:add>
</env:Body>
</env:Envelope>
If anybody could offer any guidance it would be highly appreciated.
Figured it out, its suppose to be.
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:platformMsgs="urn:messages_2016_2.platform.webservices.netsuite.com" xmlns:platformCore="urn:core_2016_2.platform.webservices.netsuite.com"
xmlns:platformCommon="urn:common_2016_2.platform.webservices.netsuite.com" xmlns:tranSales="urn:sales_2016_2.transactions.webservices.netsuite.com" xmlns:tranCust="urn:customers_2016_2.transactions.webservices.netsuite.com">
<env:Header>
<platformMsgs:tokenPassport>
<platformCore:account>1234_SB1</platformCore:account>
<platformCore:consumerKey>***FILTERED***</platformCore:consumerKey>
<platformCore:token>***FILTERED***</platformCore:token>
<platformCore:nonce>s975gqhodufgodiueroh</platformCore:nonce>
<platformCore:timestamp>1531918396</platformCore:timestamp>
<platformCore:signature algorithm="HMAC-SHA256">p0z56JDUsN+ksjhfe8HEhdEU(WJff7u+0Yee7Axk=
</platformCore:signature>
</platformMsgs:tokenPassport>
<platformMsgs:preferences>
<platformMsgs:ignoreReadOnlyFields>true</platformMsgs:ignoreReadOnlyFields>
</platformMsgs:preferences>
</env:Header>
<env:Body>
<platformMsgs:add>
<platformMsgs:record xsi:type="tranCust:ReturnAuthorization">
<tranCust:entity internalId="173436">
<platformCore:name>C030420 John Thomas</platformCore:name>
</tranCust:entity>
<tranCust:itemList>
<tranCust:item>
<tranCust:item internalId="22138" type="inventoryItem"/>
</tranCust:item>
</tranCust:itemList>
</platformMsgs:record>
</platformMsgs:add>
</env:Body>
</env:Envelope>
You have to create a initialize for the same.
So once the Sales order is created then we can do a Authorization Return on it once it successfully goes through the process.
More info at : https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_N3508536.html
Make sure the SOAPAction is set to initialize.
I am supposed to access a a publicly accessible API (https://ABCInsuranceCoreApp.ng.bluemix.net/ABCInsurance/ProductService) using POST method. It accepts an XML Payload of the form
<Customer>
<Age>40</Age>
<Gender>M</Gender>
<Location>IBM</Location>
</Customer>
and returns a list of products. The API works in a REST-Client and tested.
What I have done in the Apigee API Dev Platform is as follows.
Default ProxyEndpoint:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProxyEndpoint name="default">
<Flows>
<Flow name="default">
<Request>
<Step>
<Name>AssignCustomerData</Name>
</Step>
<Step>
<Name>ExecuteProductService</Name>
</Step>
</Request>
<Response>
<Step>
<Name>ParseProductList</Name>
</Step>
</Response>
</Flow>
</Flows>
<HTTPProxyConnection>
<BasePath>/v1/abcinsproductservice</BasePath>
<VirtualHost>default</VirtualHost>
</HTTPProxyConnection>
<RouteRule name="default"/>
</ProxyEndpoint>
AssignCustomerData is an AssignMessage Policy and it looks like..
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="AssignCustomerData">
<DisplayName>AssignCustomerData</DisplayName>
<AssignTo createNew="true" type="request">CustomerData</AssignTo>
<Set>
<Payload contentType="text/xml">
<Customer>
<Age>40</Age>
<Gender>M</Gender>
<Location>IBM</Location>
</Customer>
</Payload>
<Verb>POST</Verb>
</Set>
</AssignMessage>
ExecuteProductService is a service callout and it looks like..
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="ExecuteProductService">
<!-- Send the message we just made to the target, and save the result -->
<Request variable="CustomerData"/>
<Response>ProductList</Response>
<HTTPTargetConnection>
<URL>https://ABCInsuranceCoreApp.ng.bluemix.net/ABCInsurance/ProductService</URL>
</HTTPTargetConnection>
</ServiceCallout>
and ParseProductList is an ExtractVriable Policy which looks like..
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="ParseProductList">
<DisplayName>ParseProductList</DisplayName>
<FaultRules/>
<Properties/>
<VariablePrefix>products</VariablePrefix>
<XMLPayload>
<Variable name="name" type="string">
<XPath>//Products/Product[1]/Name</XPath>
</Variable>
</XMLPayload>
</ExtractVariables>
I have dilligently followed the samples, however the arrangement does not work. I am confused as to where the error is.
The trace is not working either..
Can you pls help out..
Many thanks in advance
Amitava
I looks like you need to add Source to your ExtractVariables policy, as in:
<Source clearPayload="false">ProductList</Source>
Also, I'm curious why you are doing this with a ServiceCallout (rather than just routing to your target service via a TargetEndpoint)? I don't see a RouteRule in your ProxyEndpoint. Without a RouteRule, you are creating an Echo Server will will simply reflect back whatever comes in. To stop that from happening, you would need to add a RaiseFault policy after your ExtractVariables policy to terminate the call.
Or, perhaps you are just showing us a snippet and there is really more to it?
The way I see it is,
<Step>
<Name>ParseProductList</Name>
</Step>
Should be a Request Step.
So your proxy becomes,
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProxyEndpoint name="default">
<Flows>
<Flow name="default">
<Request>
<Step>
<Name>AssignCustomerData</Name>
</Step>
<Step>
<Name>ExecuteProductService</Name>
</Step>
<Step>
<Name>ParseProductList</Name>
</Step>
</Request>
<Response/>
</Flow>
</Flows>
<HTTPProxyConnection>
<BasePath>/v1/abcinsproductservice</BasePath>
<VirtualHost>default</VirtualHost>
</HTTPProxyConnection>
<RouteRule name="default"/>
</ProxyEndpoint>
I am trying to batch delete videos from the user his YouTube favorites using the YouTube v2 API. (See also https://developers.google.com/youtube/2.0/developers_guide_protocol_batch_processing)
Posting videos to the favorites in batch works nicely; and I can also remove single videos from the favorites without problem (This rules out a problem with authentication).
My request body is as follows, where VIDEOID1 and VIDEOID2 are the <yt:favoriteId>Ids found in their corresponding video xml:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:yt='http://gdata.youtube.com/schemas/2007'>
<batch:operation type="delete"/>
<entry><id>VIDEOID1</id></entry>
<entry><id>VIDEOID2</id></entry>
</feed>
This is the response I get back however, where UserID ofcourse is the userID of the user and BatchID is the BatchID given by the service:
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://www.w3.org/2005/Atom'>
<id>https://gdata.youtube.com/feeds/api/users/USERID/favorites/batch/BATCHID</id>
<updated>2014-01-31T14:50:54.948Z</updated>
<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#favorite'/>
<title>Batch Feed</title>
<entry xmlns:batch='http://schemas.google.com/gdata/batch'>
<id>VIDEOID1</id>
<updated>2014-01-31T14:50:54.948Z</updated>
<title>Error</title>
<content>Invalid entry Id/Uri</content>
<batch:status code='400' reason='Invalid entry Id/Uri'/>
</entry>
<entry xmlns:batch='http://schemas.google.com/gdata/batch'>
<id>VIDEOID2</id>
<updated>2014-01-31T14:50:54.949Z</updated>
<title>Error</title>
<content>Invalid entry Id/Uri</content>
<batch:status code='400' reason='Invalid entry Id/Uri'/>
</entry>
</feed>
It states Invalid entry Id/Uri for the videos I try to remove, while when I remove them by singular delete request with the same ID, it works.
Is batch deleting videos from favorites not supported, or am I missing something?
I've got it to work, thanks to this question and answer: Batch deleting videos using YouTube API and HTTpWebRequest
The trick was using the user its userId instead of default, and to use to complete video URL as id.
The batch URL looks like this:
https://gdata.youtube.com/feeds/api/users/USERID/favorites/batch?v=2&alt=json
The request looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:batch='http://schemas.google.com/gdata/batch' xmlns:yt='http://gdata.youtube.com/schemas/2007'>
<batch:operation type="delete"/>
<entry>
<id>https://gdata.youtube.com/feeds/api/users/USERID/favorites/VIDEOID1?v=2</id>
</entry>
<entry>
<id>https://gdata.youtube.com/feeds/api/users/USERID/favorites/VIDEOID2?v=2</id>
</entry>
</feed>
Cannot figure out how to properly send request to get all records, which are corresponding to the meeting.
From this request mysite.adobeconnect.com/api/xml?action=sco-info&sco-id=1087877981
I get such response:
<?xml version="1.0" encoding="utf-8"?>
<results>
<status code="ok"/>
<sco account-id="1051298934" disabled="" display-seq="0" folder-id="1057190786" icon="meeting" lang="en" max-retries="" sco-id="1087877981" source-sco-id="1051270965" type="meeting" version="3">
<date-begin>2013-08-20T03:15:00.000-07:00</date-begin>
<date-created>2013-08-20T03:30:04.200-07:00</date-created>
<date-end>2013-08-20T04:15:00.000-07:00</date-end>
<date-modified>2013-08-20T06:39:45.927-07:00</date-modified>
<name>DevTeam Meeting 2</name>
<url-path>/devmeeting2/</url-path>
<update-linked-item>true</update-linked-item>
</sco>
<source-sco>
<source-sco account-id="1051298934" disabled="" display-seq="0" folder-id="1051270964" icon="meeting" lang="en" max-retries="" sco-id="1051270965" source-sco-id="-8888" type="meeting" version="1">
<date-created>2012-05-15T14:09:07.453-07:00</date-created>
<date-modified>2013-08-13T16:33:57.600-07:00</date-modified>
<name>Default Meeting Template</name>
<url-path>/defaultmeetingtemplate/</url-path>
</source-sco></source-sco>
</results>
Where I see folder-id="1057190786" and sco-id="1087877981", but when I'm trying to get records for this meeting, using folder-id or sco-id according to documentation with requests
mysite.adobeconnect.com/api/xml?action=list-recordings&folder-id=1057190786
or
mysite.adobeconnect.com/api/xml?action=list-recordings&folder-id=1087877981
I receive:
<?xml version="1.0" encoding="utf-8"?>
<results>
<status code="invalid">
<invalid field="action" type="enum" subcode="no-such-item"/>
</status>
</results>
You should use another API method to get the recordings. They listed in the "scos" container, "url-path" element is what you need.
You should try the sco-contents method...
/api/xml?action=sco-contents&filter-icon=archive&sco-id=1087877981
Get your meeting contents calling sco-contents
You will find your records in those sco with icon="archive"
Don't use "list-recordings" as is not available anymore.
Reference (Sep. 20, 2016)
Provides a list of recordings (FLV and MP4) for a specified folder. The service and hence the API is no longer available.
Docs here.
I have an xml type grails.converters.deep.XML
<?xml version="1.0" encoding="UTF-8"?>
<list>
<customer>
<name>A</name>
<age>1</age>
</customer>
<customer>
<name>B</name>
<age>2</age>
</customer>
<customer>
<name>C</name>
<age>3</age>
</customer>
</list>
How do I get each customers and how do I convert it to customer domain object?
Thanks,
Nimmy
I think the deep converters have been deprecated. The new way is supposed to be something like:
XML.use( 'deep' ){ ... }
http://johnrellis.blogspot.co.uk/2009/11/grails-and-json-are-pretty-groovy.html
But you should really be using the new render as json functionality in grails 2
http://grails.org/doc/latest/guide/theWebLayer.html#xmlAndJSON