I am trying to use pub-sub method to subscribe to the events of a specific user. I am able to successfully authenticate the user but when I call the pub-sub url I get the following error.
{"meta":{"error_detail":"Unsupported API version 1.1, unless called with an OAuth header","code":404,"error_type":"endpoint_error","time":1480394928,"message":"Not Found","user_xid":""},"data":{}}
Code: This code is called inside the success callback of the OAuth2.0 Authentication.
var subscription_url = "https://jawbone.com/nudge/api/v.1.1/users/@me/pubsub?webhook=https://*****/pushJawbone";
$http.post(
subscription_url, {
headers: {
'Authorization': "Bearer " + accessToken
}
}
).success(
function(response) {
console.log("Jawbone User Subscription Successful" + response);
}
).error(
function(error) {
console.log("Jawbone sub unsucessful: " + JSON.stringify(error));
}
)
The issue is not Jawbone API. The problem was in the angular $http method. For some reason with the above code it is not sending the headers at all so the OAuth error. It works fine when I use the below code.
$http({
method: 'POST',
url: subscription_url,
headers: {
'Authorization': 'Bearer ' + accessToken
}
}).success(
function(response) {
console.log("Jawbone User Subscription Successful" + response);
}
).error(
function(error) {
console.log("Jawbone sub unsucessful: " + JSON.stringify(error));
}
)
Thanks Ray for all the help.