1

問題: JSON 応答を生成するリモート サーバー上の Rest Web サービスに ajax post 要求を送信しようとしています。

Advanced Rest Client、および同様の URL と投稿データの cURL でテストしているときに、必要な応答を取得していますが、jquery を介して同じ要求を送信しようとすると、要求はHTTP 400 Status Code (The request sent by client was syntactically incorrect). POSTだけでなくGETでも発生します。

jquery関数は次のとおりです。

$.support.cors = true; 
    $.ajax({     
    type: "POST",
    url: 'http://localhost:8089/myschool/rest/report/firstrequest/json',
     data:'{"studentList":[{"name":"Abhi","marks":"23"}], "classGID":"9de6f363-cb53-4845-ab7e-1e7c8bc7b33b","subjectGID":"1fd61614-5027-4daf-ac52-33c18cc86afd","School":"LKSEC"}',  
   dataType:"json",
   contentType: "application/json; charset=utf-8",
   cache:"false",
   async:"true",
   processdata:"false",
   success: function(html)
    {
        ss=html; 
        console.log(ss);
    },
   error:function(error)
   {
    console.log(error.status)
   },
   complete:function(html){
   console.log()
   }
        });

cURL は次のとおりです。

    curl -X POST -H "Content-Type: application/json" 
-d '{"studentList":[{"name":"Abhi","marks":"23"}], "classGID":"9de6f363-cb53-4845-ab7e-1e7c8bc7b33b","subjectGID":"1fd61614-5027-4daf-ac52-33c18cc86afd","School":"LKSEC"}' 
http://localhost:8089/myschool/rest/report/firstrequest/json
4

0 に答える 0