api - BigCommerce 的回应更加明确

标签 api httpresponse api-design bigcommerce

当程序尝试发布已存在的货件时,BigCommerce 能否更改其 API 响应以使其更加清晰?

将货件发布到 BigCommerce 时,如果货件已存在,您会收到以下错误消息。

<?xml version="1.0"?>
<errors>
    <error>
        <status>400</status>
        <message>The field 'quantity' is invalid.</message>
        <details>
            <invalid_reason>The quantity specified is greater than the quantity of the product that is available to ship.</invalid_reason>
            <available_quantity>0</available_quantity>
            <order_product_id>628</order_product_id>
        </details>
    </error>
</errors>

我同意这是一个错误的要求,但这与商品的数量无关。我们可以对 messageinvalid_reason 执行类似以下操作吗?

The shipment [insert ID here] already exists and cannot be added.

这将使 API 更加可用。

最佳答案

查询订单产品资源时,有可用的发货数量,当您创建发货时,可用数量会减少到 0。

最初,发货 POST 成功,因为有效负载中指定的数量与订单的数量匹配。如果您要将发货发布到已发货的订单,则可用数量实际上为 0,并且当您在有效负载中为数量指定正整数时,该数量无效且大于可用数量,因此错误是准确的.

关于api - BigCommerce 的回应更加明确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17886266/

相关文章:

java - 预期为 BEGIN_ARRAY,但使用 Retrofit 后却为 BEGIN_OBJECT

javascript - 重定向到新页面提交 : this. props.history.push

具有多个范围的 http 请求返回 HTTP/1.1 200 OK

java - 如何读取php代码对android java代码的响应

rest - 如何为导出端点设计REST API?

rest - 如何在RESTful API设计中处理错误数据类型和响应消息

c - 为队列设计调整大小函数

html - Cocoa:从字符串显示 HTML

java - 更改从 Forecast api 服务接收的 JSON 单位数据

node.js - Nodejs + Expressjs 将 http 响应作为缓冲区获取