Third Light Developer Exchange

Code and templating community forum for developers and software integrators

You are not logged in.

Announcement

If you wish to join the Developer Exchange, please contact your account manager - this is to avoid unnecessary spam in the forums. Many thanks for your understanding.

#1 2014-11-18 14:27:50

satishd
Member
Registered: 2014-11-18
Posts: 40

Unable to instantiate IMS.API

Hi There,

I am trying to instantiate the API object in an json request, but I always get "undefined" error

        var objAPI = new IMS.API({imsHost:"mythirdlightserver.com"});

could you please advise me whats wrong with the above statement.

Regards
Satish

Offline

#2 2014-11-18 14:37:48

dominic
Third Light Staff
Registered: 2013-06-06
Posts: 119

Re: Unable to instantiate IMS.API

Hi Satish,

You need to include the definition of the IMS API client, and the supporting library - in the case of Third Light's published Javascript clients, this would be either Prototype or JQuery. (See the "Invoking the client" section of the documentation page at https://www.thirdlight.com/docs/display … ipt+Client).

Dominic

Offline

#3 2014-11-19 15:36:28

satishd
Member
Registered: 2014-11-18
Posts: 40

Re: Unable to instantiate IMS.API

Thanks Dominic,

I have tried the javascript client as mentioned in your previous reply, but I am not able to login through the script -

myIMSClient.Login("myid", "mypassword");

after the above statement, javascript throws an error- the error is as below

-----------

ims-api-1.1.js (line 613)

TypeError: document.getElementsByTagName(...)[0] is undefined
document.getElementsByTagName('body')[0].appendChild(scriptTag);}

-------------

Please find the complete script- I am trying to login and adding note to the image file whose reference is 26490552737. Please advise where things going wrong.

Thanks
Satish

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <!-- Prototype library. See http://www.prototypejs.org/ -->
    <script src="http://myserver.thirdlight.com/j/external/prototype-1.7.0.0.js"></script>
    <!-- IMS API Client -->

    <script src="http://myserver.thirdlight.com/j/external/ims-api-1.1.js"></script>
    <script>
        var myIMSClient = new IMS.API({ "imsHost": "http://myserver.thirdlight.com/","syncWithWebSession":"false" });
       // var mySessionId = "E63YFVPkGTiw3BLPJYAtMeo8bk1w39qq";
        //myIMSClient.setSessionId(mySessionId);
        myIMSClient.Login("myid", "mypassword");
        myIMSClient.request("Files.AddHistoryNote", { "assetId":"26490552737","note": "This is a note" },
            {
                onSuccess: function (e) {alert('success');},
                onFailure: function (e) {alert('failed');}
           
            });

  myIMSClient.observeSuccess("Files.AddHistoryNote", function (e) {
            var apiResponse = e.memo.response;
            alert("A history note has been added to the file with ID:" +
                    apiResponse.assetId +
                    " The new history note has ID: " +
                    apiResponse.historyNoteId);
        });

    </script>
</head>
<body>
</body>
</html>

Offline

Board footer