IBM MFP 7.1 passing parameter from native Android Application - always undefined

56 Views Asked by At

I am using Android Studio 2.1.2 and IBM MFP 7.1. I have configured the native studio application as described in the documentation here https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/7.1/quick-start/android-quick-start/

I am able to successfully connect to the MF Server.

The issue I am having is passing parameters to the adapters. I have placed Logger point in the adapter code as follows:

function listTasksByUserName(username){

var baseUrl = "/Rest/v1/tasks";

WL.Logger.info("The username passed to the listTasksByUserName is: " + username);

var input = {
        method : 'get',
        returnedContentType : 'json',
        path : baseUrl,
        parameters : {
            "mUserName" : username
        }
    };

    return WL.Server.invokeHttp(input);

}

My java implementation is :

//create the adapter URI
    URI adapterPath = null;
    try {
        adapterPath = new URI("/adapters/TasksAdapter/listTasksByUserName");
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }

    //create the request
    String username="caseworker";
    WLResourceRequest request = new WLResourceRequest(adapterPath,WLResourceRequest.GET);
    request.setQueryParameter("params", username);
    request.send(new MyInvokeListener());
}

the out put from the logs is as follows: [12/1/16 11:53:44:992 EST] 0000013f ht.integration.js.JavaScriptIntegrationLibraryImplementation I The username passed to the listTasksByUserName is: undefined [project AndroidNativeApiTest] [12/1/16 11:53:58:999 EST] 00000085 ht.integration.js.JavaScriptIntegrationLibraryImplementation I The username passed to the listTasksByUserName is: undefined [project AndroidNativeApiTest]

Any help is appreciated.

1

There are 1 best solutions below

0
Spindoctor On

Have to use the exact parameter name as follows and provide the values as literals!!!!!

request.setQueryParameter("params", "[\'"+ username + "\']");