我在针对现有订单创建BC装运时遇到问题。

我正在使用基本身份验证

JSON请求为
{“ order_address_id”:2,“ items”:[{“ order_product_id”:164,“ quantity”:1},{“ order_product_id”:124,“ quantity”:1}],“ tracking_number”:“ abcd1234”}

代码如下:

    String storeurl="storeaddress"+"/orders/"+BCordernumber+"/shipments";
    URL url = new URL(storeurl);
    HttpURLConnection httpcon = (HttpURLConnection) url.openConnection();
    httpcon.setRequestMethod("POST");
    httpcon.setRequestProperty("Authorization", encodeBase64());
    httpcon.setRequestProperty("Accept", "application/json");
    httpcon.setDoOutput(true);
    httpcon.setRequestProperty("Content-Type", "application/json");

    OutputStreamWriter put = new OutputStreamWriter(httpcon.getOutputStream());
    put.write(jsondata);
    put.flush();
    put.close();

    int result = httpcon.getResponseCode();


关于为什么我会收到此400错误的任何想法都很棒

谢谢
提前

最佳答案

我已经意识到自己的错误,我使用的是product_id,而不是order_product_id。

都好

10-04 15:46