Jason Cheek
Posts: 0
Joined: Sun Jan 12, 2014 8:00 am

Correct usage of the session token in the request header via javascript

Is this the correct way to pass the session token when executing a service request from javascript?

serviceLogoutUser.execute({
data: {
//no params
},
header: {
"X-Appery-Session-Token": nl.localDB.sessionToken
},
error: function(jqXHR, textStatus, errorThrown) {
eventMessageHandler.serviceFailed('logout', jqXHR);
},
success: self.close // close page and return to login screen
});

I ask because I keep getting a "DBUO001/Unauthorised" error when using the above but it works fine when I manually test the service.

Image

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Correct usage of the session token in the request header via javascript

Jason,

Use: "headers" instead of "header" to define request headers.

The correct code is:pre

serviceLogoutUser.execute({
data: {
//no params
},
headers: {
"X-Appery-Session-Token": nl.localDB.sessionToken
},
error: function(jqXHR, textStatus, errorThrown) {
eventMessageHandler.serviceFailed('logout', jqXHR);
},
success: self.close // close page and return to login screen
});/pre

Also please take a look at this post https://getsatisfaction.com/apperyio/...

Jason Cheek
Posts: 0
Joined: Sun Jan 12, 2014 8:00 am

Correct usage of the session token in the request header via javascript

facepalm Oh of all the noob mistakes!

Thank you, that was the problem. It works perfectly now.

Return to “Issues”