我在针对现有订单创建BC货件时遇到问题。
我正在使用基本身份验证
JSON请求是 {" order_address_id":2"项目":[{" order_product_id" 164"量":1},{&#34 ; order_product_id" 124"量":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错误
由于 提前
答案 0 :(得分:2)
我意识到自己的错误,我使用的是product_id而不是order_product_id。
一切都很好