8.6.10. Using an endpoint API

8.6.10.1. Introduction

This procedure shows how:

  • Run an endpoint locally

  • Retrieve the answer

  • Have the corresponding .json

  • Know the model of the response and have an example of it

By clicking on the `Try it out` button, it is possible to test the selected query and the tool generates the query to use with curl.
The Procedure to run an endpoint specifies how to use the swagger GUI to select an API, execute the request, retrieve the response and curl of the request.
However, this request inherits the rights (and therefore the token) of the request creator.
To make a request with different rights, refer to Procedure to modify the token associated with the request.

8.6.10.2. Prerequisites

User : member of Administrator group


8.6.10.3. Preliminary operations


8.6.10.4. Procedure to acces to API

../../_images/HOME_REP2.PNG
  • Click on the button (4) `API` in the title bar.
    The following screen is displayed.
../../_images/GCENTER-API-01.PNG

8.6.10.5. Procedure to run an endpoint

To illustrate this example, the API chosen is the one that lists the GCaps connected to GCenter.

  • Select the `Gcaps` theme from the list of existing themes (5).

  • Click on the API `GET/api/gcap/ (Administrators, Operator) Get all the GCaps linked to the GCenter`.
    The window below is displayed.
    ../../_images/GCENTER-API-02.PNG

    Astuce

    For some endpoints, it is mandatory to enter parameters before running it.

  • Click on the button (2) `Try it out`.
    The window is changed ...
    ../../_images/GCENTER-API-05.PNG
  • Click on the button (1) `Execute`.
    The request is launched and the next window is displayed.
    ../../_images/GCENTER-API-06.PNG
    This window has several zones:
    • The display zone (2) `Curl` for the Curl query

    • Display zone (3) `URL` for URL request

    • Zone (4) `Server response`:

      • The Return `Code` (5):
        • If the code is set to `200` then the execution has been completed correctly.

        • If the message `code 400 Undocumented Error Bad Request` is displayed, verify that the required parameters are entered.

      • The body of the answer (6): refer to Overview of the API interface
      • The field detailing the answer header (7)
      • The value in ms of the query duration (8)
      • The `Download` button to download the corresponding .json file
    • The `Responses` zone
      This zone displays different information depending on the use of the link `Model` or `Example Value`.
    • Or the output model (`Model`): refer to Overview of the API interface

    • An example of the answer in the expected field with values for example (`Example Value`): refer to Overview of the API interface
      The values are:
      • For integer type (value 0)

      • For type string (value = string)

      • For boolean type (value = true)


8.6.10.6. Procedure to modify the token associated with the request

../../_images/GCENTER-API-08.PNG
  • Click the button (1).
    The `Available authorizations` window is displayed:
    ../../_images/GBOX-API-10.PNG

    There are two options:

    • Or the use of an apikey (token previously created)

    • Or the use of an authorization by name and password of an account previously created

  • To use an apikey (token previously created):

  • Paste the token in the `value` field

  • Validate by clicking on the `Authorize` field

  • Close window with the `Close` field

Note

The token can have a limited life: see The `API Keys` section of the `Accounts` submenu.

  • To use an authorization:

  • Click in the `Username field
    The list of existing accounts is displayed.
  • Enter the account password

  • Validate by clicking on the `Authorize` field

  • Close window with the `Close` field