错误:由于不活动,您的会话已过期。 ATG REST API会话确认号码不匹配

时间:2016-06-02 13:31:15

标签: angular-http atg atg-dynamo atg-droplet atg-dust

我正在使用REST API开发ATG门户,所有ATG API都使用PostMan进行测试。 当我开始使用JS时,它会出错。以下是测试代码:

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:

  

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

     

对象{数据:“您的会话由于不活动而过期。”,状态:409,配置:对象,statusText:“冲突”}

会话确认号只能访问一次,之后会产生500个内部服务器错误(这个逻辑我写的不包含在这里),

当我从浏览器手动获取会话确认号码并在代码中手动将其作为_dynSessConf值提供

时,

登录正在运行

请帮忙。

1 个答案:

答案 0 :(得分:0)

像org.json这样的一些JSON库在解析大型long时遇到问题。 对于我的代码来说,它们会产生略微不同的大长度值,

SessionConfirmationNumber通过JSON返回作为Long的数据类型,因为SessionConfirmationNumber很大,我得到了舍入值。

我已经使用xmlHttp请求解决了这个问题。

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

感谢上帝:)

相关问题