Shipstation'da bir ürünü güncellemekte sorun yaşıyorum.
Yanıtı nasıl biçimlendirmem gerektiğini görmek için bu 2 bağlantıyı kullanıyorum:
https://www.shipstation.com/docs/api/products/update/ https://www.any-api.com/shipstation_com/shipstation_com/docs/Products/_products_productId_/PUT
Doğru takip ettiğime inanıyorum, ancak her zaman "Nesne başvurusu bir nesne örneğine ayarlanmadı"diyen bir 500 hata mesajı alıyorum.
Ürünün niteliklerini almak için GET isteğini kullanıyorum.
Sonra değiştirilmesi gereken öznitelikleri güncellerim ve içinde saklarım data
(bu bir nesne dizisidir). Sonra verileri göndermek için PUT isteğini kullanıyorum.
Bu ilgili koddur:
function updateProducts(authString, data) {
var baseProductUrl = `https://ssapi.shipstation.com/products/`;
for(var d = 0; d < data.products.length; d++) { //for each product I'd like to update...
var raw = data.products[d];
raw = JSON.stringify(raw);
var requestOptions = {
method: 'PUT',
headers: {
"Authorization": `Basic ${authString}`,
"Content-Type": `application/json`,
},
body: raw,
redirect: 'follow'
};
var productUrl = `${baseProductUrl}${data.products[d].productId}`;
UrlFetchApp.fetch(productUrl, requestOptions);
}
}
Bu nedir raw
(shipstation'a gönderdiğim veriler) şöyle görünüyor: :
Boş değerler sadece GET isteğinden aldığım şeydir. Bu özelliklerin boş kalmasını tercih ederim.
{"aliases":null,
"productId":123456789, //placeholder
"sku":"sku", //placeholder
"name":"UV Bulb - 1GPM - 10\"",
"price":19.99,
"defaultCost":null,
"length":2,
"width":2,
"height":13,
"weightOz":7,
"internalNotes":null,
"fulfillmentSku":null,
"active":true,
"productCategory":null,
"productType":null,
"warehouseLocation":null,
"defaultCarrierCode":null,
"defaultServiceCode":null,
"defaultPackageCode":null,
"defaultIntlCarrierCode":null,
"defaultIntlServiceCode":null,
"defaultIntlPackageCode":null,
"defaultConfirmation":null,
"defaultIntlConfirmation":null,
"customsDescription":"UV Bulb - 1GPM - 10\"", //attribute I'd like to update
"customsValue":9.99, //attribute I'd like to update
"customsTariffNo":null,
"customsCountryCode":"US",
"noCustoms":null,
"tags":null}
Yani herhangi bir ipucu var mı, yoksa daha önce Shipstation'ın API'sini kullanan ve bir PUT isteği yapan var mı? Neyi kaçırıyorum?