Getting data from an invoke operation - Forum - Mobile - Progress Community

Getting data from an invoke operation

 Forum

Getting data from an invoke operation

  • Does somebody have a working example of using an invoke operation in a mobile service, and using it in the mobile app builder?

    So I this is my mobile service:

    @openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").

    @progress.service.resourceMapping(type="REST", operation="invoke", URI="/AuthenticateUser", alias="", mediaType="application/json").

    PROCEDURE AuthenticateUser:

    DEFINE INPUT  PARAMETER username AS CHARACTER   NO-UNDO.

    DEFINE OUTPUT PARAMETER userObj  AS DECIMAL     NO-UNDO INITIAL 0.

    ...

    1) When I test the service with the Postman rest client, and I don't give any parameter (empty http request body), I get the correct response: 

    {

        "response": {

            "userObj": 0

        }

    }

    When I give a request parameter username, I keep getting "415 unsupported media type" , even when i put the request in any json format that I try.

    2) When I import the service in the mobile app builder, and i create the service and the edit mapping: then I get the request parameter "username" , but on the response tab everyting is empy, there are no parameters to chose from. So he doesn't recognize the outputparameter userObj of my Progress procedure.

    When I test the service in my browser, I was able to intercept the communication, and the browser effectively sends this JSON as request for an empty username:

    {"request":{"username":""}}

    And gets this response:

    {

        "response": {

            "userObj": 0

        }

    }

    I tried to put the same request JSON format in the Postman rest client, but I keep getting "415 unsupported media type" there.

    Also, when I manually create a parameter response-userObj in the response tab in the Mobile App builder, this doesn't receive the value from the response.

  • Output parameters for invoke operations must be added manually.

    -Shelley

  • i am also facing the same problem. i am not able to map the output parameter from response tab mapping. i manually added the output parameter to the service but after invoke, nothing was returned. i invoked the service using java script and able to get the return value using _retval but was not able to get the output parameter value.

  • Name your response parameter exactly as your output parameter of your Progress procedure function that you assigned your invoke operation to.

  • i did the same but no luck. after invoke nothing returned. i then used the return value to retrieve the output value.

  • Did you test that your service is working and returning the correct response? You can test this in internet explorer, F12, "network" tab, and there start capturing. Then do your click or refresh your page or whatever is invoking your service on your page. Then you will see the REST request and the response. Check the name of the response parameter, and if it has a value.

  • i will try that. thanks