"객체 참조 설정하지 않는 인스턴스의 개체"오류를 업데이트할 때 제품을 가진 ShipStation 의 API

0

질문

나는 데 문제가 업데이트 제품에서 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 (는 개체의 배열). 그때 사용하는 요청이 데이터를 전송합니다.

이것은 관련 코드:

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)처럼 보인: Null 값은 단순히 내가에서 받는 GET 요청을 합니다. 나는 그들을 좋아한 속성이 편 비어 있습니다.

{"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 의 API 전 및 완료를 넣어 요청이 있으십니까? 나는 무엇이 없는가?

1

최고의 응답

0

스크립트에서는 방법에 대해 다음과 같은정하고 있습니까?

From:

var requestOptions = { 

  method: 'PUT',
  headers: {
    "Authorization": `Basic ${authString}`,
    "Content-Type": `application/json`,       
  },

  body: raw,
  redirect: 'follow'
};

하기:

var requestOptions = { 
  method: 'PUT',
  headers: {
    "Authorization": `Basic ${authString}`,
  },
  payload: raw,
  contentType: "application/json",
};

참고:

2021-11-24 00:30:32

그것을 믿을 수 없었 같은 간단한 수정입니다. 감사합니다! 이중에서 응답자
oscark

@oscark 감사에 대한 답변. 난 당신의 문제가 해결되었습니다. 에 대한 철자,당신을 감사에 대한 확인하고 있습니다. 고 싶을 수도 있습니다. 감사합니다.
Tanaike

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................