My API accept this data and tried in a postman its working fine :
http://{URL}/password/email
Method : POST
Header : [{"key":"Accept","value":"application/json","description":""}
, {"key":"Content-Type","value":"application/x-www-form-
urlencoded","description":""}]
Body : only working if I send key:value in x-www-form-urlencoded.
my IONIC 2 code is :
return new Promise((resolve, reject) => {
let headers = new Headers();
headers.append('Accept', 'application/json');
headers.append('Content-Type', 'application/x-www-form-urlencoded');
let body = new FormData();
body.append('email', email);
let options = new RequestOptions({ headers: headers });
this.http.post(config.API_URL+"/password/email" ,body , options)
.subscribe(res => {
resolve(res.json());
}, (err) => {
reject(err.json());
});
});
and I am getting error
POST {URL}/password/email 422 (Unprocessable Entity) polyfills.js:3
I don't know what's wrong with my code?
JSON.stringify(body)inthis.http.post(config.API_URL+"/password/email" ,JSON.stringify(body) , options)- Niladri