WCF Rest Starter Kit OnGetItems returns IEnumerable<KeyValuePair<string,BusinessObject>>
On serialization , It becomes
<ItemInfoList>
<ItemInfo>
<EditLink>http://localhost:1394/BService.svc/1</EditLink>
<Item>
<Name>Foundations</Name>
</Item>
</ItemInfo>
<ItemInfo>
<EditLink>http://localhost:1394/Service.svc/2</EditLink>
<Item>
<Name>Hitchhikers guide</Name>
</Item>
</ItemInfo>
</ItemInfoList>
I want to change the ItemInfo and ItemInfoList to something more sensible like a business entity name. How can I do that?
As far as I can tell, you can't change these names because the data contracts, ItemInfosList and ItemInfo, are being provided for you by REST kit, so you're giving up some of the control by using CollectionServiceBase.
Related
I am trying to create a data file for my application with XML as input and map it to my HP Exstream variables. But when I am trying to save the file it is giving me error "No customer-level tag specified! Engine will not process.". I am not sure how to resolve this error. There is no customer level information I want in my input. Can anyone explain what is this error and how to resolve it?
What HP Exstream is telling you is that you have not defined a tag that will allow Exstream to know when a customer begins and ends. This does not have to be a tag that says <customer-level>, but rather the tag you are using in the XML to determine where a customer begins and ends.
When you are using an XML file as input, you may be dealing with multiple customers take this for example:
<item>
<address>
<line>a</line>
<line>b</line>
</address>
<body>Hello World</body>
</item>
<item>
<address>
<line>c</line>
<line>d</line>
</address>
<body>Hello Universe</body>
</item>
I would be using the <item> tag to tell HP Exstream where my customer begins and ends.
You can choose the customer tag in the properties of the tags.
I want to add products using AddItem API call in eBay with UPC code. I have searched about it, but did not get any specific answer. I want to ask what will be the UPC code for item that will be added in to the eBay list.
Please help me.
Thanks & Regards
This is an old question, and surely you have moved on. But surprisingly no other related examples here on stackoverflow or at developer.ebay.com were to be found when I ran into a similar need with the eBay API AddFixedPriceItem (almost exactly identical to AddItem but aimed at non-auction listings). Here is the XML request structure that worked for me in POSTing to this API for UPC or ISBN coded products illustrated using the Verify version of the API:
<?xml version="1.0" encoding="utf-8"?>
<VerifyAddFixedPriceItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>YOUR TOKEN STRING HERE</eBayAuthToken>
</RequesterCredentials>
<Item>
<AutoPay>false</AutoPay>
<Country>US</Country>
<Currency>USD</Currency>
<ListingType>FixedPriceItem</ListingType>
<ListingDuration>Days_30</ListingDuration>
<PaymentMethods>PayPal</PaymentMethods>
<PaymentMethods>VisaMC</PaymentMethods>
<PayPalEmailAddress>SELLER PAYPAL EMAIL ADDR HERE</PayPalEmailAddress>
<ProductListingDetails>
<UPC>BARCODE HERE</UPC>
<EAN>Does not apply</EAN>
<ListIfNoProduct>true</ListIfNoProduct>
<UseStockPhotoURLAsGallery>true</UseStockPhotoURLAsGallery>
</ProductListingDetails>
<ShippingDetails>
<ShippingServiceOptions>
<ShippingService>USPSFirstClass</ShippingService>
<ShippingServiceCost currencyID="USD">3.00</ShippingServiceCost>
<ShippingServiceAdditionalCost>1.00</ShippingServiceAdditionalCost>
<ShippingServicePriority>1</ShippingServicePriority>
<ShippingService>USPSPriority</ShippingService>
<ShippingServiceCost currencyID="USD">5.00</ShippingServiceCost>
<ShippingServiceAdditionalCost>2.00</ShippingServiceAdditionalCost>
<ShippingServicePriority>2</ShippingServicePriority>
</ShippingServiceOptions>
<ShippingType>Flat</ShippingType>
</ShippingDetails>
<ShipToLocations>US</ShipToLocations>
<Quantity>1</Quantity>
<Site>US</Site>
<StartPrice currencyID="USD">1.99</StartPrice>
<Title>YOUR GREAT ITEM TITLE</Title>
<Location>CITY,STATE HERE</Location>
<PictureDetails>
<GalleryType>Gallery</GalleryType>
</PictureDetails>
<DispatchTimeMax>3</DispatchTimeMax>
<ReturnPolicy>
<RefundOption>MoneyBack</RefundOption>
<Refund>Money Back</Refund>
<ReturnsWithinOption>Days_30</ReturnsWithinOption>
<ReturnsWithin>30 Days</ReturnsWithin>
<ReturnsAcceptedOption>ReturnsAccepted</ReturnsAcceptedOption>
<ReturnsAccepted>Returns Accepted</ReturnsAccepted>
<ShippingCostPaidByOption>Buyer</ShippingCostPaidByOption>
<ShippingCostPaidBy>Buyer</ShippingCostPaidBy>
</ReturnPolicy>
<ConditionID>EBAY CONDITION CODE</ConditionID>
<ConditionDisplayName>EBAY CONDITION DISPLAY TEXT</ConditionDisplayName>
</Item>
<ErrorLanguage>en_US</ErrorLanguage>
<WarningLevel>Low</WarningLevel>
</VerifyAddFixedPriceItemRequest>
This is the VerifyAddFixedPriceItem call, which again is very very similar to the VerifyAddItem API. You can use the Verify version of either to check out that the request will be OK once debugged (just don't trust the fees either of them report even in production). The AddFixedPriceItem API adds the item to eBay using the UPC code only, via the eBay product catalog content. You can replace <UPC> and </UPC> with <ISBN> and </ISBN> for books as well. You could use this as an XML template for the VerifyAddItem and AddItem APIs as well.
Text in CAPS needs to be customized, the shipping prices are just random for illustration. I ran this using eBay Trading API version 1001 (as of this posting date you can ignore the warnings about no seller profile being in place). Also you can find the eBay condition codes and name text here: eBay Condition ID Values and Names
Hope this helps you or someone else that comes along with a similar need.
I am trying to use the eBay API call RelistFixedPriceItem relist an item as fixed price which has been listed as an auction before.
The "interesting part" of my XML request looks like this:
<RelistFixedPriceItemRequest>
<Item>
<ListingType>
FixedPriceItem
</ListingType>
</Item>
</RelistFixedPriceItemRequest>
But still, eBay responds that I can't use the ListingType I used ("FixedPriceItem") but should use "FixedPriceItem" (the same) instead:
<RelistFixedPriceItemResponse xmlns="urn:ebay:apis:eBLBaseComponents">
<Timestamp>2013-06-21T14:14:52.951Z</Timestamp>
<Ack>Failure</Ack>
<Errors>
<ShortMessage>Unsupported ListingType.</ShortMessage>
<LongMessage>Valid Listing type for fixedprice apis are FixedPriceItem and StoresFixedPrice.</LongMessage>
<ErrorCode>21916286</ErrorCode>
<SeverityCode>Error</SeverityCode>
<ErrorClassification>RequestError</ErrorClassification>
</Errors>
<Version>827</Version>
<Build>E827_UNI_API5_16161102_R1</Build>
</RelistFixedPriceItemResponse>
Has anyone run into this issue - or found a workaround?
Nothing in their API documentation states that this shouldn't be possible. It certainly is on ebay.com where you can change the listing type when you relist an item.
Well, If you look at their API documentation's Sample XML, you would notice that they do not use
<ListingType>
FixedPriceItem
</ListingType>
That suggests to me that, when you use the RelistFixedPriceItem call you do not have to specify the Listing Type to be FixedPriceItem
I do agree that it is a confusing error.
I have a small dilemma.
If you have the following URI endpoints:
/item
/item/{id}
If I make a GET request to /item I expect something like this:
<Items>
<Item>...</Item>
<Item>...</Item>
...
</Items>
If I make a GET request to /item/{id} I expect something like this:
<Item>
...
</Item>
Some of my fellow team members argue we should design the API so when someone does a GET for /item/{id} it should be returned as a collection of a single element. Like this:
<Items>
<Item>...</Item>
</Items>
This seems wrong to me. Does it seem wrong to you too? Please explain why, so I might convince either myself to go with the always wrapped version of the resource or my fellow devs to go with the non-wrapped single resource.
Most importantly, there is no right and wrong answer to this question.
However, here is what I think.
If you want to return a single item, I would tend to do this:
GET /Item/{Id}
=>
<Item>
...
</Item>
If the {Id} does not exist then the server should return a 404.
If I want to return a collection of items, I would do
GET /Items
=>
<Items>
<Item>...</Item>
<Item>...</Item>
</Items>
If there are no items, then it should return a 200 with an empty <Items/> element.
If it really makes it easier for the client to deal with a collection that has just one element, then you could do something like this.
GET /Items?Id={Id}
=>
<Items>
<Item> ... </Item>
</Items>
The difference here is that if the {Id} did not exist then I would tend to return 200 not a 404.
Seems counterintuitive to me. You are potentially saving code effort on the client side by having one way of reading data from your two GET methods. This is of course countered by having extra code to wrap your single GET method in a collection.
If you want real world examples,
twitter returns an individual
representation of a resource not
wrapped in a collection
basecamp, an
early proponent of REST based API,
also follows this model
EDIT: Our API uses this HTTP status code structure
I think your colleagues are right if you think about the consuming side of your REST service, which then can handle every response as a collection. And there's one more thing: If the {id} did not exist, what does your service return? Nothing? Then the consumer has to check for either a null result or error response, a single element or a collection. According to my experience getting a collection in any case (which may be empty) is the most convenient way to be served by a REST service.
i want a particular sequence to be generated in a random manner
<item>
<i1>abc</i1>
<i2>pqr</i2>
</item>
now how can i make an xsd where <i1> can come before <i2> ?
use the 'all' indicator as shown on the w3schools website