consume API from command line RRS feed

  • Question

  • Hi,

    I published en R script with publishService and would like to come the API from another computer from the Linux shell. How can I use curl to consume the service?


    Tuesday, April 24, 2018 7:04 PM

All replies

  • Hello,

    - All services take a consume URL and http method like so:


    POST /api/:name/:version

    OR with out the version, it will reach the latest version

    POST /api/:name


    - Things to keep in mind

    1. These calls require authentication first so your Authorization bearer access token (from a /login) needs to be included in the header

    2. The content-type in application/json

    3. The body of the request is json hence you need to structure the payload appropriately.


    - Tips

    If you have mrsdeploy, any easy way to get the feel of what the HTTP invocation looks like in its "raw form" (e.g. what curl would basically use) is to turn on some verbose logging.




    # -- do your consume call here and you can see/capture the full HTTP I/O, headers, payload, ect... --



    With this info you can structure a curl request as use see fit.

    2. OR -- If you do not want to use Curl, Your published service has a swagger.json, so you can generate a client in your preferred language based on that.



    Tuesday, April 24, 2018 8:00 PM