2 Replies Latest reply on Sep 22, 2014 7:37 AM by saurabhs RSS
    saurabhs Newbie

    Error on redirect from another application

    Hi

    I am trying to redirect my request from another application (J2EE) to a Thingworx Portal created by us.

    I have added the following in the URL as well :  appKey=4865d586-a267-4e52-bc63-7d97c2757412&x-thingworx-session=true


    But on the first first hit it gives an error page (401 unauthorised) and if I refresh the page the URL is picked up and gets me into the application.


    Could you please advise the possible problem. Do I need to make some configuration changes.


    I am using Thingworx 5.0.x and on 64 bit.


    I am attaching the access logs as below:



    Error Log

    202.41.204.10 - - "GET /Thingworx/Mashups/ValidateWelcomePage?appKey=90dc2dea-6506-472c-8dd1-88a342cbbd1d&x-thingworx-session=true HTTP/1.1" 401 1149


    Correct Page Access Logs

    202.41.204.10 - - "GET /Thingworx/Mashups/ValidateWelcomePage?appKey=90dc2dea-6506-472c-8dd1-88a342cbbd1d&x-thingworx-session=true HTTP/1.1" 302 -

    202.41.204.10 - - "GET /Thingworx/Runtime/index.html HTTP/1.1" 304 -

    202.41.204.10 - - "POST /Thingworx/Subsystems/PlatformSubsystem/Services/GetAllStyleDefinitions HTTP/1.1" 200 169475

    202.41.204.10 - - "POST /Thingworx/Subsystems/PlatformSubsystem/Services/GetAllStateDefinitions HTTP/1.1" 200 18612

    202.41.204.10 - - "POST /Thingworx/Resources/RuntimeLocalizationFunctions/Services/GetEffectiveTokens HTTP/1.1" 200 11450

    202.41.204.10 - - "POST /Thingworx/Resources/CurrentSessionInfo/Services/GetGlobalSessionValues?Accept=application%2Fjson-compressed&Content-Type=application%2Fjson HTTP/1.1" 200 3881

    202.41.204.10 - - "POST /Thingworx/Resources/CurrentSessionInfo/Services/GetCurrentUserExtensionProperties?Accept=application%2Fjson-compressed&Content-Type=application%2Fjson HTTP/1.1" 200 2321

    202.41.204.10 - - "POST /Thingworx/Resources/CurrentSessionInfo/Services/GetPersistentValue?Accept=application%2Fjson-compressed&Content-Type=application%2Fjson HTTP/1.1" 200 34

    202.41.204.10 - - "POST /Thingworx/Resources/CurrentSessionInfo/Services/GetPersistentValue?Accept=application%2Fjson-compressed&Content-Type=application%2Fjson HTTP/1.1" 200 12




    The URL is same in both the cases. All I am doing is pressing F5 after the first 401 unauthorised failure.



    Kindly advise


    Regards

    Saurabh


      • Error on redirect from another application
        adam Creator

        Hi Saurabh,

         

        Have you tested this programmatically? We've noticed some weirdness when using a web browser to make these calls that you don't see when making them programmatically.


        – Adam



        • Error on redirect from another application
          saurabhs Newbie

          Hi

           


          I am trying to call the URL from a Spring Web application deployed on the same server.

          I am using a redirect to hit the URL from the Spring. 



          Also, I tried to use the below mentioned code snippet. But I a still getting 401 error.





           try {

              timeout=0;

                 HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();

                 connection.setConnectTimeout(timeout);

                 connection.setReadTimeout(timeout);

                 //connection.setRequestMethod("HEAD");

                 //connection.set

                 int responseCode = connection.getResponseCode();

                 return (200 <= responseCode && responseCode <= 399);

             } catch (IOException exception) {

                 return false;

             }