批量调用响应400错误请求

时间:2016-03-20 21:15:34

标签: ajax odata sap batch-processing

我正在进行Ajax批量调用,根据oData批处理标准格式化所有数据,但每次使用POST方法运行调用,我得到400个错误请求。

另一方面,如果我复制粘贴相同的请求并在REST客户端邮递员中运行我接受了202,这有点奇怪,有人可以指出,如果某个地方我正在做这不对? 这是请求:

//request body defined here

--batch_1458506017890
Content-Type: multipart/mixed; boundary=changeset_51

--changeset_51
Content-Type: application/http
Content-Transfer-Encoding: binary

PUT ObjectRAItemSet(ResourceAssignment='0000287725') HTTP/1.1
Content-Type: application/json

{"PeriodTotalCost":"16.23","PeriodHours":"0.000"}

--changeset_51
Content-Type: application/http
Content-Transfer-Encoding: binary

PUT ObjectRAItemSet(ResourceAssignment='0000287725') HTTP/1.1
Content-Type: application/json

{"PeriodTotalCost":"11.2","PeriodHours":"0.000"}

--changeset_51--
--batch_1458506017890--

这是ajax电话:

var boundary = new Date().getTime().toString();

$.ajax({
                  method: 'POST',
                  url: serverURL+'$batch',
                  data: batchRequestBody, //request body defined before
                    //dataType: 'json',
                  //processData: false,
                  contentType: 'multipart/mixed;boundary=batch_'+ boundary,
                  //contentType: 'application/json; charset=utf-8',
                  success:function(res){
                    console.log(res, 'success');
                 },
                 error:function(e){
                     console.error(e, 'error');
                 }
             });

1 个答案:

答案 0 :(得分:0)

所以,我修复了它,我的服务器(nginx)设置了内部cookie 谢谢你的帮助