javascript - $http post return 400 on google chrome angularjs -
well have issue when utilize $http.post of angularjs on google chrome returned error 400 bad request, when tried on mozilla firefox works fine!
this $http services code
$http({ 'method': "post", 'url': "http://example.com", 'data': data, 'withcredentials': true, 'cache': false, headers: { 'content-type': 'application/json', 'authtokens': sessionservices.get('userlogin').userlogintokens, 'jsessionid': sessionservices.get('jsessionid') } }). success(function(data, response, headers, status) { console.log("sucess"); }). error(function(data, response) { console.log("failed"); }); this illustration info intput on $http request self
data = [123415, 32324123, 1123124123, 1213123] note*
the url submitted backend in domain illustration deployed application on http://example1.com while backend on http://example.com, @ first thought cors issue apparently passed alternative phone call , when moved sec phone call post request self returned error 400
apparently chrome ignores custom headers alternative set 'application/json', in chrome returned differently. see returned phone call below
remote address:example1.com request url:example.com request method:post status code:400 bad request
request headers view source accept:application/json, text/plain, */* accept-encoding:gzip,deflate accept-language:en-us,en;q=0.8,id;q=0.6,ms;q=0.4 authtokens:13f4ca0d-eb30-435b-b313-a78ed8fff5ef connection:keep-alive content-length:313 content-type:application/json;charset=utf-8 application/json cookie:jsessionid=f524fafc1178ee3451a7d82cbad9be87 host:http://example1.com jsessionid:f524fafc1178ee3451a7d82cbad9be87 origin:http://example.com referer:http://example.com user-agent:mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, gecko) chrome/37.0.2062.124 safari/537.36 x-requested-with:xmlhttprequest request payload view source [d6fece6d-fd4b-4377-b326-7e7cdafbe02b, 6240a840-29a7-4e16-899a-2db0fde6ffdd,…] 0: "d6fece6d-fd4b-4377-b326-7e7cdafbe02b" 1: "6240a840-29a7-4e16-899a-2db0fde6ffdd" 2: "794ae064-38f3-4324-8cda-5afaabe2347d" 3: "41d28490-624d-418d-8fda-4a0ed8c65aa2" 4: "38e06d09-1d33-42d2-b6a2-e06548743a1a" 5: "7f8e92c8-4217-443a-9830-3da78a75b1a6" 6: "ed31b19a-2b2a-4fd7-99b8-b5b61d6a881f" 7: "2b1b8636-d342-4114-9de3-40d42003790f" response headers view source access-control-allow-credentials:true access-control-allow-origin:example1.com access-control-expose-headers:jsessionid connection:close content-language:en content-length:990 content-type:text/html;charset=utf-8 date:wed, 15 oct 2014 15:25:48 gmt server:apache-coyote/1.1 vary:origin do have issue ?? guys help me ??
maybe it's because of wrong content-type header:
content-type:application/json;charset=utf-8 application/json in javascript code there's typo:
headers: { 'content-type': 'application/json', it has -type, capital t. default application/json anyway can remove line.
it chrome merges content-type , content-type whereas firefox sends either 2 separate headers or 1 of them.
javascript angularjs google-chrome http post
No comments:
Post a Comment