Example: Adding an API Version

This example walks you through adding a new version to an existing API in Akana API Platform by using the platform API rather than the user interface. There are three options when creating a new version; this example adds a new version by cloning the original API. For examples of all three options, see POST /api/apis/{APIID}/versions.

This exercise assumes that you already have a valid login for Akana API Platform and are an API Admin.

Note: If you added the API, you automatically become the first API Admin. See Example: Adding an API by providing the full API definition.

Before starting, you will need:

  • A valid UserID and password for platform access.
  • The APIID for the API you want to add a version to.
  • The APIVersionID for the version that you want to clone.

To add an API version in the Akana API Platform by cloning the original version, using the API

  1. Log in via the API, POST /api/login operation, using your own email and password in the body of the operation instead of the placeholder values given below.
    • HTTP method: POST
    • URL: https://{hostname}/api/login
    • Accept header: application/json
    • Content-Type header: application/json
    • Request Body:
      {
        "email":"MyEmailAddress",
        "password":"MyPassword"
      }

    The platform API returns the login cookie, which you'll need to send with the request headers for any operation that requires login, and the CSRF cookie, which you'll need to use to put together the CSRF header if required by platform settings (not covered in this exercise: see Example: Using the CSRF header).

  2. Add the API version, using the POST /api/apis/{APIID}/versions operation. In your API call, use the following, substituting the correct APIID in the URL and also in the request body:
    • HTTP method: POST
    • URL: https://{hostname}/api/apis/{APIID}versions
    • Accept header: application/vnd.soa.v81+json
    • Content-Type header: application/vnd.soa.v81+json
    • CSRF header: include it if needed. If you are not sure whether it's needed or not, refer to CSRF Prevention on the Platform.
    • Request Body (Key values are: Name for the new version, valid SourceAPIVersionID, CloneDesign value of true):
      {
        "APIVersionInfo":{
          "Name":"Version 2"
        },
        "AddAPIImplementationRequest":{
          "CreateMechanism":"PROXY"
        },
        "CloneAPIVersionRequest":{
          "SourceAPIVersionID":"f825dd89-87be-4f7f-b615-e5b19842a0e6.acmepaymentscorp",
          "CloneDesign":true,
          "CloneImplementations":true
        }
      }
  3. You should get an HTTP 200 response, with the full version object including the newly-assigned APIVersionID.Take the APIVersionID; you will use this later.
  4. When done, remember to log out using the GET /api/login/endsession operation. Use the following values:
    • URL: https://{hostname}/api/login/endsession
    • Accept header: application/json