Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Not applicable

How to fix problem with sendJsonRequest promise in connectdialog.js?

I've made several little changes in my connector and now it can't send JsonRequest to server.

$scope.onTestConnectionClicked = function () {

     console.log("testConnection init");

     var promise = input.serverside.sendJsonRequest("testConnection", $scope.username, $scope.password);

     console.log(promise);

     console.log("testConnection promise generated");

     promise.catch(function(a) {

         console.log("Catched ex");

         console.log(a);

     });

     promise.then( function ( info ) {

        $scope.connectionInfo = info.qMessage;

       $scope.connectionSuccessful = info.qMessage.indexOf( "OK" ) !== -1;

    } );

  };

Error I get, when onTestConnectionCliked function fires:

Error from Engine: Object {jsonrpc: "2.0", id: 51, error: Object}

Error object: code: -1 message: "Unknown error" parameter: "General exception"

My HandleJsonRequest method, from class QvAmoCrmServer (extends QvxServer)

(Two implementations, same effect)

First one:

      public override string HandleJsonRequest(string method, string[] userParameters, QvxConnection connection)

        {

            QvDataContractResponse response;

            QvxLog.Log(QvxLogFacility.Application, QvxLogSeverity.Debug, "Handle json Request > " + method);

            string provider, host, username, password;

            connection.MParameters.TryGetValue("provider", out provider); // Set to the name of the connector by QlikView Engine

            connection.MParameters.TryGetValue("userid", out username); // Set when creating new connection or from inside the QlikView Management Console (QMC)

            connection.MParameters.TryGetValue("password", out password); // Same as for username

            connection.MParameters.TryGetValue("host", out host); // Defined when calling createNewConnection in connectdialog.js

            switch (method)

            {

                case "getInfo":

                    response = getInfo();

                    break;

                case "getDatabases":

                    response = getDatabases(username, password);

                    break;

                case "getTables":

                    response = getTables(username, password, connection, userParameters[0], userParameters[1]);

                    break;

                case "getFields":

                    response = getFields(username, password, connection, userParameters[0], userParameters[1], userParameters[2]);

                    break;

                case "testConnection":

                    response = testConnection(userParameters[0], userParameters[1]);

                    break;

                default:

                    response = new Info { qMessage = "Unknown command" };

                    break;

            }

           return ToJson(response);    // serializes response into JSON string

          

        }

And another:

         public override string HandleJsonRequest(string method, string[] userParameters, QvxConnection connection)

        {

    

            return JsonConvert.SerializeObject(new Info {qMessage = "Test response"});

        }

Error screenshot: Program Manager (271 kb) закачан 11 июня 2015 г. Joxi

2 Replies
Not applicable

Re: How to fix problem with sendJsonRequest promise in connectdialog.js?

Method HandleJsonRequest didn't call at all.

First implementation executes Log method, but log is empty.

emjay1000
New Contributor

Re: How to fix problem with sendJsonRequest promise in connectdialog.js?

Hey,

Have you solved the sendJsonRequest-problem?

If yes, can you give me an advice? I am facing a similar issue and have no idea which mistake I made that I get this error.

Thanks in advance!

Community Browser