-
Notifications
You must be signed in to change notification settings - Fork 104
Is there any way to insert attribute in xml tag? #22
Comments
If you follow the code to where they actually convert the JSON into XML you'll see that it uses
|
hello, when i pass this Object: xml({Item: [{BuyItNowPrice: [{ _attr: { currencyID: 'USD'}}, 18]}]}) === "<BuyItNowPrice currencyID="USD">18" But when I pass as a parameter of this function ebay.xmlRequest({
the function deepToArray convert [{"Item":[{"BuyItNowPrice":[{"_attr":[{"currencyID":["USD"]}]}]},{"BuyItNowPrice":[18]}]}] for which: xml([{"AddItemsRequest":[{"_attr":{"xmlns":"urn:ebay:apis:eBLBaseComponents"}},{"RequesterCredentials":[{"eBayAuthToken":"Token"}]},{"Item":[{"BuyItNowPrice":[{"_attr":[{"currencyID":["USD"]}]}]},{"BuyItNowPrice":[18]}]}]}
|
You're passing it as an object literal and not as an xml object.
Try:
params: xml({ .... })
…On Fri, Feb 24, 2017 at 2:45 PM, urielcastrillon08 ***@***.*** > wrote:
hello,
i have the same problem
when i pass this Object:
xml({Item: [{BuyItNowPrice: [{ _attr: { currencyID: 'USD'}}, 18]}]}) ===
"<BuyItNowPrice currencyID="USD">18"
But when I pass as a parameter of this function
ebay.xmlRequest({
serviceName: 'Trading',
opType: 'AddItems',
// app/environment
devId: this.devId,
certId: this.certId,
appId: this.appId,
sandbox: true,
// per user
authToken: this.authToken,
params: {Item: [{BuyItNowPrice: [{ _attr: { currencyID: 'USD'}}, 18]}]}
}, (error, results) => {
...
});
the function deepToArray convert
this object : {Item: [{BuyItNowPrice: [{ _attr: { currencyID: 'USD'}},
18]}]} in
[{"Item":[{"BuyItNowPrice":[{"_attr":[{"currencyID":["USD"]
}]}]},{"BuyItNowPrice":[18]}]}]
for which:
xml([{"AddItemsRequest":[{"_attr":{"xmlns":"urn:ebay:apis:
eBLBaseComponents"}},{"RequesterCredentials":[{"
eBayAuthToken":"Token"}]},{"Item":[{"BuyItNowPrice":[{"_
attr":[{"currencyID":["USD"]}]}]},{"BuyItNowPrice":[18]}]}]}
]) Token 18
I really appreciate. It if we could solve the problem
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#22 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABWSY7xRF6OSGnKzr2DF8sdlRbmCuhmOks5rf12fgaJpZM4GhZOp>
.
|
thank you for your answer thehuey. |
is possible change the function deepToArray for this: exports.deepToArray = function deepToArray(obj) { if (.isArray(obj)) {
} |
@thehuey Are you sure you're meant to manually convert to XML before passing the params? Doing so produces the correct (escaped) XML, however, when this is passed to here, the manually converted xml param is escaped when converted again (and therefore 500s eBay's API). i.e. it's sending;
If I don't run the params through xml first, i.e. params = { .. }, then it produces the same output as @urielcastrillon08 above. Any ideas..? |
Hello. I need to use this method.
http://developer.ebay.com/devzone/finding/callref/findItemsByProduct.html
I don't know how to insert attribute "type" in xml tag. Please, help.
The text was updated successfully, but these errors were encountered: