REST API POST returning 400 Syntax error I wrote a REST plugin for posting data to my Drupal site, When I send JSON data from browser it is returning the error {readyState: 4, responseText: "{"error":"Syntax error"}", responseJSON: Object, status: 400, statusText: "Bad Request"} but it is working fine in Postman. What might be the issue?

The data I am send is  {"name" : "user", "pass" : "userpass"} 

I am also adding the following headers in request.

"Content-Type", 'application/json'
"Accept", 'application/json'
You can use Postman to generate your code



Click here to change code language