Error: Your session expired due to inactivity. ATG REST API session confirmation Number Missmatch

1.3k views Asked by At

I am working on ATG portal using REST API, all ATG API's are tested using PostMan. It is giving an error when I started working in JS. below is the Test Code:

http({
            method : "GET",
            url : "http://IP:PORT/rest/model/atg/rest/SessionConfirmationActor/getSessionConfirmationNumber"               
         }).then(function mySucces(response){
              // localStorage.setItem("getSessionConfirmationNumer", response.data.sessionConfirmationNumber);
              // localStorage.getItem("getSessionConfirmationNumer");   
            http({
                    method : "GET",
                    url : "http://IP:PORT/rest/model/atg/userprofiling/ProfileActor/login?_dynSessConf="+response.data.sessionConfirmationNumber+"&login=atgcust1&password=atgcust1",
                    // url : "http://IP:PORT/rest/model/atg/userprofiling/ProfileActor/login",
                    // data:formData
                 }).then(function mySucces(response){
                      console.log("done");
                 },function errorCallback(response) {
                    console.log(response);

                });
         });

OutPut from Console:

angular.js:10722 GET http://IP:PORT/rest/model/atg/userprofiling/ProfileActor/login?_dynSessConf=9030570900570011195&login=atgcust1&password=atgcust1 409 (Conflict)(anonymous function) @ angular.js:10722p @ angular.js:10515g @ angular.js:10222(anonymous function) @ angular.js:14745n.$eval @ angular.js:15989n.$digest @ angular.js:15800n.$apply @ angular.js:16097(anonymous function) @ angular.js:23554n.event.dispatch @ jQuery-2.1.4.min.js:3r.handle @ jQuery-2.1.4.min.js:3 functions.js:75

Object {data: "Your session expired due to inactivity.", status: 409, config: Object, statusText: "Conflict"}

Session Confirmation Number Can be Accessible only once after that it will give 500 internal server error (This Logic I have written not included here),

Login is working when I get session confirmation Number manually from browser and giving that as _dynSessConf value manually in the code

Please help.

1

There are 1 answers

0
Syam Nath On BEST ANSWER

Some JSON libraries like org.json have a problem parsing large longs. They yield a slightly different value for large longs which is exactly happend to my code,

SessionConfirmationNumber Returning Via JSON as Data type of Long and I was getting rounded value as the SessionConfirmationNumber was large.

I have used xmlHttp request for solving this issue.

var xmlHttp = new XMLHttpRequest();
        xmlHttp.open( "GET", "http://IP:PORT/rest/model/atg/rest/SessionConfirmationActor/getSessionConfirmationNumber", false ); 
        xmlHttp.send();
        console.log(xmlHttp.responseText);

Thank God :)