Search code examples
ajaxpostrequestpolymerhttp-status-code-400

bad request error with polymer component POST function


I'm trying to create a Polymer component that make a simple POST httprequest.

<link rel="import" href="/components/core-ajax/core-ajax.html">

<polymer-element name="test-insert">
  <template>

   <core-ajax auto method="POST" contentType="application/json"  url="/api/accounts" body='{"email":user@example.com}'>
</core-ajax>
</template>

This is the , i get always a ERR 400, BAD REQUEST.


Solution

  • body='{"email":user@example.com}' should be body='{"email":"user@example.com"}'. Note the quotes around the email.