I followed the guidance at Smart of the Home to produce the following code in a provider for an Ionic 2 App.
return new Promise(resolve => {
// We're using Angular HTTP provider to request the data,
// then on the response, it'll map the JSON data to a parsed JS object.
// Next, we process the data and resolve the promise with the new data.
let headers = new Headers();
headers.append('Content-Type','application/vnd.alertme.zoo-6.1+json');
headers.append('Accept','application/vnd.alertme.zoo-6.1+json');
headers.append('X-Omnia-Client','Hive Web Dashboard');
let options = new RequestOptions({ headers: headers });
const body = JSON.stringify({
"sessions": [{
"username": "<username>",
"password": "<password>",
"caller": "WEB"
}]
});
this.http.post('https://api.prod.bgchprod.info:443/omnia/auth/sessions', body, options)
.map(res => res.json())
.subscribe(data => {
console.log(data)
});
});
Now when I try the Postman collection very kindly provided by the author of the tutorial I linked above, the call returns perfectly fine, but returns a 401 when fired through the app.
Inspecting the requests made, everything appears identical. I cannot fathom what is going wrong?