मैं कर रहा हूँ परेशानी हो रही है अद्यतन करने के लिए एक उत्पाद में Shipstation.
मैं का उपयोग किया गया है इन 2 देखने के लिए लिंक मैं कैसे करना चाहिए प्रारूप प्रतिक्रिया:
https://www.shipstation.com/docs/api/products/update/ https://www.any-api.com/shipstation_com/shipstation_com/docs/Products/_products_productId_/PUT
मुझे विश्वास है कि मैं पीछा कर रहा हूँ यह सही ढंग से, लेकिन मैं हमेशा एक 500 त्रुटि संदेश कह "ऑब्जेक्ट संदर्भ नहीं सेट करने के लिए एक वस्तु का एक उदाहरण".
मैं का उपयोग किया गया है को प्राप्त करने के लिए अनुरोध प्राप्त उत्पाद की विशेषताओं.
तो मैं अद्यतन गुण की जरूरत है कि किया जा करने के लिए बदल गया है, और यह दुकान में data
(जो है वस्तुओं की एक सरणी). तो मैं का उपयोग करें put अनुरोध भेजने के लिए डेटा.
यह प्रासंगिक कोड:
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);
}
}
यह है क्या raw
(डेटा मैं भेज रहा हूँ करने के लिए ShipStation) की तरह दिखता है:
अशक्त मूल्यों बस रहे हैं क्या मैं से प्राप्त अनुरोध प्राप्त करते हैं । मैं पसंद करते हैं, उन विशेषताओं को खाली रहना.
{"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}
तो क्या किसी के पास किसी भी संकेत है, या किसी को भी इस्तेमाल किया ShipStation एपीआई से पहले और एक डाल का अनुरोध किया है? मैं क्या कर रहा हूँ याद आ रही है?