Node_SDK sessionService needed

0 votes
Hi, me again,

We have been working with node_sdk for a while, recently we have the need to varify if a session Id is valid or  not, so we need the sessionService api.

We tried to write sessionService function calls by ourselves , but always got error on that.

Could you please include sessionService api in nodejs sdk as well? If so, could you please let us know when it approximately can be added in?


asked Jan 30, 2015 in App42 Cloud API-BaaS by Bob Anoop (19 points)
recategorized Jan 30, 2015 by sushil

1 Answer

0 votes

Hello Bob,

As of now, session service is not available in App42 NODE SDK.

Can you please let us know what is the exception message that you are getting and what is the code snippet for method that you have written in session service?

Himanshu Sharma

answered Jan 30, 2015 by hs00105 (2,005 points)
We have written following code inside userService:

getSession: function (userName,callback) {
                var requestURL = App42.URL("session");
                var queryParams = {};
                var signParams = App42Service.populateSignParams();
                var meteheaderParams = App42Service.populateMetaHeaderParams();
                var headerParams = App42Service._merge(signParams,meteheaderParams)
                var jsonBody = {"app42":{"session":{"userName": userName}}};
                signParams.body = JSON.stringify(jsonBody);
                App42Log.debug("JSON Body is : " +  JSON.stringify(jsonBody))
                //signParams.userName = userName;
                var signature = App42Util.signature(App42.secretKey,signParams)
                headerParams.signature = signature
                App42Log.debug("signature is : " + signature)
                App42Connection.executeGet(requestURL, queryParams,headerParams,callback);

The error is like:

<html><head><title>Apache Tomcat/6.0.39 - Error report</title><style><!--H1 {f
SyntaxError: Unexpected token <
    at Object.parse (native)

when the callback parse function is called.

Could you please add get session function into priority list?

Hello Bob,

Everything which you write is good, only the mistake we find in your code is that getSession in Session Service is a post method. Kindly change the last line of code with below code & it will work for you.

App42Connection.executePost(requestURL, queryParams,headerParams,JSON.stringify(jsonBody),callback);

Do let me know if it helps.

Himanshu Sharma
works very well, thank you very much.
Hello Bob,

Good to hear that your query has been resolved. Let us know if you have more questions for us.

HImanshu Sharma
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on