After testing my API in Postman, I found that it works fine with the following data:
URL: http://{URL}/password/email
Method: POST
Header:
[{"key":"Accept","value":"application/json","description":""}
,{"key":"Content-Type","value":"application/x-www-form-urlencoded","description":""}]
Body: The API only works when key:value pairs are sent in x-www-form-urlencoded format.
In my IONIC 2 code:
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());
});
});
However, when I try to execute the code, I encounter an error:
POST {URL}/password/email 422 (Unprocessable Entity) polyfills.js:3
I'm unsure of what is causing this issue in my code. Can someone help me troubleshoot?