Search code examples
javascriptparametersibm-mobilefirstworklight-adapters

Worklight Client invoke procedure with custom BODY parameters


We are using Worklight 6.2 developing an Hybrid application. Currently we need to pass custom body parameters from the client to the worklight server when we invoke an adapter.

Is it possible to add custom body parameters (next to the defaults: adapter, procedure and parameters) in the invocation of an adapter from from an Hybrid client (Javascript API)?

Thank you in advance for your help


Solution

  • WL.Client.invokeProcedure does not allow for custom parameters.

    Then again, why would you send these to the Worklight Server specifically?
    Perhaps you mean that these parameters are parameters you need to send to a backend server?

    What you could do is simply send those as a set of parameters to the adapter procedure, where you will place those as described in the HTTP adapter tutorial.

    // ...
    // handle the parameters... 
    // ...
    
    var input = {
            method: 'post',
            returnedContentType: YOUR-RETURNED-CONTENT-TYPE,
            body: {
                content: PLACE-PARAMETERS-HERE,
                contentType: 'text/xml; charset=utf-8',
            },
        };
    
    var result = WL.Server.invokeHttp(input);