Digital Assistant and Mobile

Get Involved. Join the Conversation.

Topic

    Kantilalr
    Invalid query parameter value in MCS API
    Topic posted May 8, 2018 by Kantilalr , tagged API, Mobile 
    126 Views, 2 Comments
    Title:
    Invalid query parameter value in MCS API
    Summary:
    Invalid query parameter value in MCS API
    Content:

    Hi,

     

    I am calling rest connector from API.  Below is my code for calling rest connector.

     

    service.get('/mobile/custom/BranchAPI/BranchList', function(req,res) {

    var sdk = req.oracleMobile;

    var statusCode = 200;

    var optionsList= {};

    optionsList.uri = "/mobile/connector/BranchConnector"+"/queryResults/?query=select id,branch_code,branch_name,branch_name_ara from ABC.Branch";

    sdk.rest.get(optionsList,function(errConn, resConn,bodyConn){

    if(errConn){

    res.send(resConn.statusCode, errConn.message);

    }else{

    var bodyObject = JSON.parse(bodyConn);

    //var currentObservation = bodyObject.items[0].rows;

    var currentObservation = bodyObject;

    res.send(statusCode, currentObservation);

    }

    })

    });

     

    When I test it, it trows error below.

     

    {

      "type": "https://sample.com/services/rest/connect/exceptions/OSC-CREST-00019",

      "title": "Invalid query parameter value",

      "status": 400,

      "detail": "This query is not supported: near \"from\": syntax error",

      "instance": "https://sample.com/services/rest/connect/v1.3/queryResults/?query=select+id%2Cbranch_code%2Cbranch_name%2Cbranch_name_ara+from+ABC.Branch",

      "o:errorCode": "OSC-CREST-00019"

    }

    Comment

     

    • Martin Jarvis

      I would guess you need to properly URL encode that query string before passing it to the API so that it looks like this %2FqueryResults%2F%3Fquery%3Dselect%20id%2Cbranch_code%2Cbranch_name%2Cbranch_name_ara%20from%20ABC.Branch

      Javascript has a built in function for this:

      var uri = "my test.asp?name=ståle&car=saab";
      var res = encodeURI(uri);

      But question for you, assuming you are connecting to an external rest service, are you really exposing a database through SQL on the Internet? Sounds like a security risk to me.

      Regards

      Martin

      Oracle Mobile & Bots Product Management

    • Frank Nimphius

      Hi,

      your problem appears to be this line

      query=select+id

      This indeed is not a valid value

      Frank