I have a product with some size-variations.
For example root item has sku 20159DA2 and children have for sku 20159DA2-S, 20159DA2-XS, etc
I want to call the method bulkUpdatePriceQuantity but it gives me Bad Request telling me the sku doesn’t exists.
Here the example of the json I’m sending to Ebay
{
"requests": [{
"offers": [{
"availableQuantity": 1,
"offerId": "115388226132",
"price": {
"currency": "EUR",
"value": "69.99"
}
}],
"shipToLocationAvailability": {
"quantity": 1
},
"sku": "20159DA2-XS"
}, {
"offers": [{
"availableQuantity": 1,
"offerId": "115388226149",
"price": {
"currency": "EUR",
"value": "89.99"
}
}],
"shipToLocationAvailability": {
"quantity": 1
},
"sku": "20302DA2-S"
}, {
"offers": [{
"availableQuantity": 1,
"offerId": "115388226149",
"price": {
"currency": "EUR",
"value": "89.99"
}
}],
"shipToLocationAvailability": {
"quantity": 1
},
"sku": "20302DA2-XS"
}]
}
the beam that is coming to me is that I can not use this method for variations. But if so is there any other method I can use to update just the change quantities?
——–USING ReviseFixedPriceItem——————-
the json I have is
{
"RequesterCredentials": {
"eBayAuthToken": ""
},
"Item": {
"ItemID": "115809802256",
"Variations": {
"Variation": [{
"SKU": "STALLION_0",
"Quantity": 4
}]
}
}
}
The HttpPost is
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "TOKEN " + EBAY_TOKEN);
client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8");
client.DefaultRequestHeaders.Add("X-EBAY-C-MARKETPLACE-ID", "EBAY_IT");
client.DefaultRequestHeaders.Add("Accept", "application/json");
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var url = $"https://api.ebay.com/wsapi?callname=ReviseFixedPriceItem";
string _jsonContent = JsonConvert.SerializeObject(json);
HttpContent _httpContent = new StringContent(_jsonContent, Encoding.UTF8, HTTPManager.HTTP_POST_CONTENT_TYPE_JSON);
System.Net.Http.HttpResponseMessage response = client.PostAsync(url, _httpContent).Result;
response.EnsureSuccessStatusCode();
var resp = response.Content.ReadAsStringAsync().Result;
}
—————–USING XML—————————
<?xml version="1.0" encoding="UTF-8"?>
<ReviseFixedPriceItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<ErrorLanguage>it_IT</ErrorLanguage>
<WarningLevel>Low</WarningLevel>
<Item>
<ItemID>115711360327</ItemID>
<Variations>
<Variation>
<SKU>07000-129-M_39</SKU>
<Quantity>0</Quantity>
</Variation>
<Variation>
<SKU>07000-129-M_40</SKU>
<Quantity>1</Quantity>
</Variation>
<Variation>
<SKU>07000-129-M_41</SKU>
<Quantity>2</Quantity>
</Variation>
<Variation>
<SKU>07000-129-M_42</SKU>
<Quantity>2</Quantity>
</Variation>
<Variation>
<SKU>07000-129-M_43</SKU>
<Quantity>3</Quantity>
</Variation>
<Variation>
<SKU>07000-129-M_44</SKU>
<Quantity>1</Quantity>
</Variation>
<Variation>
<SKU>07000-129-M_45</SKU>
<Quantity>1</Quantity>
</Variation>
<Variation>
<SKU>07000-129-M_46</SKU>
<Quantity>0</Quantity>
</Variation>
<Variation>
<SKU>07000-129-M_47</SKU>
<Quantity>0</Quantity>
</Variation>
</Variations>
</Item>
and use HTTP POST with xml as parameter I get status OK but the response is Ebay Official DateTime, and I need to call ReviseFixedPriceItem
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.ebay.com/ws/api.dll");
byte[] bytes;
bytes = System.Text.Encoding.ASCII.GetBytes(xml);
request.ContentType = "text/xml; encoding='utf-8'";
request.ContentLength = bytes.Length;
request.Method = "POST";
Stream requestStream = request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.Length);
requestStream.Close();
HttpWebResponse response;
response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
Stream responseStream = response.GetResponseStream();
string responseStr = new StreamReader(responseStream).ReadToEnd();
return responseStr;
}
2
Answers
Finally I solved with XML and request.Headers with CallName
-----------------USING XML---------------------------
and use HTTP POST with xml as parameter
Checking the code and the issue about the SKU doesn’t exist, it appears that you are attempting to use the bulkUpdatePriceQuantity method in eBay, but it doesn’t support variations, because basically this method is designed for updating price and quantity information for individual items, not variations.
For updating the quantity of variations, eBay provides a separate method called ReviseFixedPriceItem instead, which allows you to update specific variation details, including quantity, price, and other attributes.
Anyway, try this JSON payload for revising the quantity of a variation using the ReviseFixedPriceItem method, an example could be:
json
Something like that could solve the internal server error:
custom header constants like "HTTPManager.HTTP_POST_CONTENT_TYPE_JSON" and "EBAY_TOKEN" with your actual eBay authorization token and any custom constants used in the code have the correct values assigned to them, I think it should work, because I am not trying to run the code, so I hope.
In the Ebay official documentation, they refer the construct of XML payload for revising the item variation quantities, a simple example would be: