Im having a problem converting the curl command below into a ionic2/angular2 code.
Im not sure if the Authorization header is passed on to the backend server since the error looks like this below not a invalid token error.
{"detail":"Authentication credentials were not provided."}
Any help is very much appreciated.
Curl Command
curl -v -H"Content-Type: application/json" -H"Authorization: Token xxxxxxxx" -XPOST -d'{"status": "True"}' https://xxx/xx/xxx/status/
Ionic2
var headers = new Headers();
headers.append("Accept", 'application/json');
headers.append('Content-Type', 'application/json' );
headers.append('Authorization', 'Token ' + "xxxxxxxx");
let options = new RequestOptions({ headers: headers });
let postParams = {
status: "True"
}
return new Promise(resolve => {
this.http.post(Uri, postParams, options).subscribe(data => {
resolve(data);
}, err => {
console.log(err.json());
});
});