Start a new topic

HTTP error registering Device for Push


Using backbone library and titanium - for 2 days (or maybe more) i am getting a http error when i am trying to register a device for Push.

The Script:

var url = (Kinvey.API_ENDPOINT + '/push/kid_PTYXXXXX/register-device').toString();

var xhr = Ti.Network.createHTTPClient({

onload: function(e) {




onerror: function(e) {

// this function is called when an error occurs, including a timeout




timeout:5000 /* in milliseconds */


xhr.setRequestHeader('Authorization', 'Kinvey ' + Kinvey.getActiveUser()._kmd.authtoken);

xhr.setRequestHeader('Content-Type', 'application/json');"POST", url);


'platform' : 'ios',

'deviceId' : token


Each time i get this:


[INFO] : code = 401;

[INFO] : error = "HTTP error";

[INFO] : source = "[object TiNetworkHTTPClient]";

[INFO] : success = 0;

[INFO] : type = error;

[INFO] : }

Any idea whats causing this?

Best, Nico


As we are using a node.js Service for several other things, i make the registerForPush POST Request on the node.js side with the informations coming from the application.

This way it works fine and as expected. :)

sadly i can't get it to work right now ... :(

QUestion: What does the request on the Kinvey-side? Just entering the token into the user-object? (If so, i propably can just save it by my own? )

Best, Nico
Yes. Either way, the headers somehow aren’t added to the request, therefore Kinvey returns a 401.
Hmm just to be clear:

with moving above you mean"POST", Kinvey.API_ENDPOINT + '/push/kid_XXXXXX/register-device');

xhr.setRequestHeader('Authorization', 'Kinvey ' + Kinvey.getActiveUser()._kmd.authtoken);

xhr.setRequestHeader('Content-Type', 'application/json');

instead of

xhr.setRequestHeader('Authorization', 'Kinvey ' + Kinvey.getActiveUser()._kmd.authtoken);

xhr.setRequestHeader('Content-Type', 'application/json');"POST", Kinvey.API_ENDPOINT + '/push/kid_XXXXXX/register-device');

I can see in the logs both the *Authorization* and *Content-Type* header are not set. If you tried moving the `` call to above `xhr.setRequestHeader`, and that didn’t work - I’d try asking around on the Titanium forums, as this seems a Titanium problem.

For me, moving the open call to the top results in making network requests successfully.
Hey Mark, thanks for your quick reply. - Sadly this does not solve the problem.

My guess:

Before updating to the new Titanium SDK 3.3.0 i received a lot of conenction errors calling the Kinveybackend. (just ios, android was fine)

After the update calling the backend works fine on ios, too. So my guess is that something changed regarding the http protocol or something like that.


Could you maybe run a test on your site using the new sdk? Cause i can't find any other error :neutral_face: (The other stuff like receiving the device token and so on works like a charm)

Best, Nico

I might be mistaken, but I do believe the `` call should be made *before* setting request headers.
Login or Signup to post a comment