We are trying to use a analytics service in predix. We have successfully generated the Access token and are able to get the time series data through time series service.
But when we are trying to use the analytics service with my angular code http request. Its throwing the 401 authorization error > Full crendential are need to access. But if i request this using Python or Postman service is working fine and we are getting required output.
Please if anyone has idea how to hit the predix analytics service from angular.
Below is the code :
$http({
method: 'POST',
url: 'https://predix-analytics-catalog-release.run.aws-usw02-pr.ice.predix.io/api/v1/catalog/analytics/315f7994-873d-4490-bf13-b21edd25e6bd/deployment',
headers: {
'authorization': ctrl.token,
'predix-zone-id': '7b836258-b05d-4abb-9b63-b6705a4c3946',
'content-type': 'application/json'
},
data: {
"time_series": [
112,
118,
132,
129,
121,
135,
148,
148,
136,
119,
104,
118
],
"params": {
"num_forecast": 6,
"method": "SE",
"period": 12
}
}
}).then(function successCallback(response) {
console.log("Excecuted")
}, function errorCallback(response) {
if (response.status = 401) { // If you have set 401
console.log("ohohoh hell yaaa");
}
});
Please add Bearer prefix in authorization header and if still error exists then please try adding origin header also.
headers: