api - 通过 ShipStation API 更新订单重量

标签 api

我正在构建一个更新订单重量的 ShipStation API 集成。它适用于属于本地 ShipStation 商店的订单(在我的例子中称为“手动订单”)。

但是,对于属于 Etsy 商店的订单(这些订单在 Etsy 中创建并由 ShipStation 导入),重量更新失败。我已经尝试过使用 additionalOptions 和不使用(它被标记为可选)。这是我的要求:

{
weight:{
  value:'39',
  units:'ounces'
},
orderKey:'1009247505',
orderNumber:'1009247505',
orderDate:'2015-04-02T18:00:50.0000000',
orderStatus:'awaiting_shipment',
billTo:{
  name:'Sophia Sun',
  company:null,
  street1:null,
  street2:null,
  street3:null,
  city:null,
  state:null,
  postalCode:null,
  country:null,
  phone:null,
  residential:null,
  addressVerified:null
},
shipTo:{
  name:'Sophia Sun',
  company:null,
  street1:'9851 NE 16TH ST',
  street2:'',
  street3:null,
  city:'BELLEVUE',
  state:'WA',
  postalCode:'98004-3426',
  country:'US',
  phone:null,
  residential:true,
  addressVerified:'Address validated successfully'
},
advancedOptions:{
  warehouseId:19400,
  nonMachinable:false,
  saturdayDelivery:false,
  containsAlcohol:false,
  mergedOrSplit:false,
  parentId:null,
  storeId:29420,
  customField1:null,
  customField2:null,
  customField3:null,
  source:null,
  billToParty:null,
  billToAccount:null,
  billToPostalCode:null,
  billToCountryCode:null
},
items:[
  {
    orderItemId:180328770,
    lineItemKey:'1018978111',
    sku:'173914528',
    name:'12 Sizes Available: Indigo Decorative Throw Zipper Pillow Cover 16x16 18x18 20x20 22x22 inches',
    imageUrl:'https://img1.etsystatic.com/036/0/7621433/il_fullxfull.544582063_aw56.jpg',
    weight:null,
    quantity:1,
    unitPrice:22,
    warehouseLocation:null,
    options:[
      {
        name:'Size',
        value:'20x20 inches'
      },
      {
        name:'Fabric',
        value:'Susanna'
      }
    ],
    productId:15935328,
    fulfillmentSku:null
  },
  {
    orderItemId:180328769,
    lineItemKey:'1018978113',
    sku:'174027396',
    name:'One Taupe, Blue, Indigo, Grey Decorative Throw Pillow Cover 8 Fabrics and 7 Sizes Grey Blue Tan Accent Pillow Cover',
    imageUrl:'https://img0.etsystatic.com/041/0/7621433/il_fullxfull.544517672_fdto.jpg',
    weight:null,
    quantity:1,
    unitPrice:22,
    warehouseLocation:null,
    options:[
      {
        name:'Size',
        value:'20x20 inches'
      },
      {
        name:'Fabric',
        value:'Honeycomb'
      }
    ],
    productId:16124487,
    fulfillmentSku:null
  },
  {
    orderItemId:180328768,
    lineItemKey:'1019027922',
    sku:'173914528',
    name:'12 Sizes Available: Indigo Decorative Throw Zipper Pillow Cover 16x16 18x18 20x20 22x22 inches',
    imageUrl:'https://img1.etsystatic.com/036/0/7621433/il_fullxfull.544582063_aw56.jpg',
    weight:null,
    quantity:1,
    unitPrice:22,
    warehouseLocation:null,
    options:[
      {
        name:'Size',
        value:'20x20 inches'
      },
      {
        name:'Fabric',
        value:'Grey Cat\'s Eye'
      }
    ],
    productId:15935328,
    fulfillmentSku:null
  },
  {
    orderItemId:180328767,
    lineItemKey:'1019027924',
    sku:'173914528',
    name:'12 Sizes Available: Indigo Decorative Throw Zipper Pillow Cover 16x16 18x18 20x20 22x22 inches',
    imageUrl:'https://img1.etsystatic.com/036/0/7621433/il_fullxfull.544582063_aw56.jpg',
    weight:null,
    quantity:1,
    unitPrice:22,
    warehouseLocation:null,
    options:[
      {
        name:'Size',
        value:'20x20 inches'
      },
      {
        name:'Fabric',
        value:'Madison'
      }
    ],
    productId:15935328,
    fulfillmentSku:null
  }
]
}

这是响应的堆栈跟踪:

{
  "Message": "An error has occurred.",
  "ExceptionMessage": "Object reference not set to an instance of an object.",
  "ExceptionType": "System.NullReferenceException",
  "StackTrace": "   at System.Web.Http.ApiController.<InvokeActionWithExceptionFilters>d__b.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Tracing.Tracers.HttpControllerTracer.<ExecuteAsyncCore>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__21`1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__0.MoveNext()"
}

那么,通过 ShipStation API 更新重量的正确方法是什么?

最佳答案

我是通过 python 来做的,将字典作为数据传递,但得到了同样的错误。我的解决方案是在发布到 shipstation 时传递具有适当内容类型的 json 编码字符串。 代码:

headers = {'Content-type': 'application/x = requests.post('https://ssapi.shipstation.com/orders/createorder', data=json.dumps(order_data),
                          auth=HTTPBasicAuth('user', 'password'),
                          headers=headers)

关于api - 通过 ShipStation API 更新订单重量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29493463/

相关文章:

javascript - 从弹出 html 调用内容脚本函数不起作用

php - 未捕获的异常 'Exception',堆栈跟踪 : #0. 中的消息 '0' PHP Insert based on API response

javascript - 如何在java脚本中的设定间隔函数中动态更改谷歌地图标记图标图像?

java - 带有@BeanParam 的空 pojo

api - Azure API 管理 OAuth 2.0 资源所有者密码流客户端 ID

java - 锁在 API 中等待,以防暴露

api - Instagram API 响应代码 400(错误请求)

c++ - 我如何找到任务栏的高度?

c# - 是否有低级网络库来嗅探和更改网络流量?

api - 如何使用 Twitter API(2022 年)获取 Twitter 关注者数量?