意外的响应代码400和SQL Server插入API,试图添加标头

时间:2019-05-28 13:18:12

标签: android api android-volley retrofit2

在此代码中在什么位置设置Header?

final RequestQueue requestQueue = Volley.newRequestQueue(ActivityBaggingListAfterValidation.this);

        Map<String, Object> params = new HashMap<String, Object>();
        params.put("RefNo", autoScanList.get(0).getRefNo());
        params.put("BagNo", autoScanList.get(0).getBagNo());
        params.put("ByHub", autoScanList.get(0).getByHub());
        params.put("ToHub", autoScanList.get(0).getToHub());
        params.put("EntryDate", autoScanList.get(0).getEntryDate());
        params.put("EntryTime", autoScanList.get(0).getEntryTime());
        params.put("EnterBy", autoScanList.get(0).getEnterBy());
        params.put("OpenBy",autoScanList.get(0).getOpenBy());
        params.put("EntryDateTime", autoScanList.get(0).getEntryDateTime());
        params.put("Topay", autoScanList.get(0).getTopay());
        params.put("COD", autoScanList.get(0).getCOD());
        params.put("Remarks", autoScanList.get(0).getRemarks());
        params.put("Destination", autoScanList.get(0).getDestination());
        params.put("EntryId", autoScanList.get(0).getEntryId());
        params.put("UploadDate", autoScanList.get(0).getUploadDate());
        params.put("VAS", autoScanList.get(0).getVAS());
        params.put("Favor", autoScanList.get(0).getFavor());
        params.put("PayMode", autoScanList.get(0).getPayMode());
        params.put("ValueIf", autoScanList.get(0).getValueIf());
        params.put("VolL", autoScanList.get(0).getVolL());
        params.put("VolB", autoScanList.get(0).getVolB());
        params.put("VolH", autoScanList.get(0).getVolH());
        params.put("VolWeight", autoScanList.get(0).getVolWeight());
        params.put("PinCode", autoScanList.get(0).getPinCode());
        params.put("AwbNo", autoScanList.get(0).getAwbNo());
        params.put("Mode", autoScanList.get(0).getMode());
        params.put("ODAArea", autoScanList.get(0).getODAArea());
        params.put("OpenedBy", autoScanList.get(0).getOpenedBy());
        params.put("Pcs", autoScanList.get(0).getPcs());
        params.put("Weight", autoScanList.get(0).getWeight());
        params.put("SLNo", autoScanList.get(0).getSLNo());
        params.put("DocType", autoScanList.get(0).getDocType());
        params.put("MFNumber", autoScanList.get(0).getMFNumber());
        params.put("BillNo", autoScanList.get(0).getBillNo());
        params.put("Content", autoScanList.get(0).getContent());
        params.put("PapperWork", autoScanList.get(0).getPapperWork());


        JsonObjectRequest req = new JsonObjectRequest(MyConfig.JSON_BASE_URL + MyConfig.TITAN + "/api/Bagging/SaveBaggingDetails",
                new JSONObject(params),
                new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject response) {
                        Log.d("response1", "onResponse: "+response.toString());
                    }
                },
                new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                VolleyLog.e("Error: ", error.getMessage());
            }
        })

        { //no semicolon or coma
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> params = new HashMap<String, String>();
                params.put("Content-Type", "application/json; charset=utf-8");
                return params;
            }

            @Override
            public String getBodyContentType() {
                return "Content-Type:application/json";
            }


        };
        requestQueue.add(req);
  

05-28 18:39:52.571 16351-16811 / com.windhans.client.titan E / Volley:   [4636] BasicNetwork.performRequest:意外的响应代码400   http://192.168.0.119/api/Bagging/SaveBaggingDetails 05-28 18:39:52.571   16351-16351 / com.windhans.client.titan E / Volley:[1] 4.onErrorResponse:   错误:

0 个答案:

没有答案