Chilkat Online Tools

DataFlex / Anypoint Platform APIs / /organizations/:organization/environments

Back to Collection Items

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sId
    Integer i
    Integer iCount_i
    String sTemp1

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    Send ComSetRequestHeader To hoHttp "X-ANYPNT-ENV-ID" "{{environment_id}}"
    // Adds the "Authorization: Bearer {{token}}" header.
    Set ComAuthToken Of hoHttp To "{{token}}"
    Send ComSetRequestHeader To hoHttp "X-ANYPNT-ORG-ID" "{{organization_id}}"

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComQuickGetSb Of hoHttp "https://domain.com/organizations/{{organization_id}}/environments" vSbResponseBody To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComLastStatus Of hoHttp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComLastHeader Of hoHttp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Procedure_Return
    End

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "resources": [
    //     {
    //       "id": "proident aute"
    //     },
    //     {
    //       "id": "in nisi adipisicing enim"
    //     }
    //   ]
    // }

    // Sample code for parsing the JSON response...
    // Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "resources" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "resources[i].id" To sId
        Move (i + 1) To i
    Loop



End_Procedure

Curl Command

curl -X GET
	-H "Authorization: Bearer {{token}}"
	-H "X-ANYPNT-ORG-ID: {{organization_id}}"
	-H "X-ANYPNT-ENV-ID: {{environment_id}}"
https://domain.com/organizations/{{organization_id}}/environments

Postman Collection Item JSON

{
  "name": "/organizations/:organization/environments",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Authorization",
        "value": "Bearer {{token}}",
        "type": "text"
      },
      {
        "key": "X-ANYPNT-ORG-ID",
        "value": "{{organization_id}}",
        "type": "text"
      },
      {
        "key": "X-ANYPNT-ENV-ID",
        "value": "{{environment_id}}",
        "type": "text"
      }
    ],
    "url": {
      "raw": "{{url}}/organizations/{{organization_id}}/environments",
      "host": [
        "{{url}}"
      ],
      "path": [
        "organizations",
        "{{organization_id}}",
        "environments"
      ]
    },
    "description": "Returns a list of environment identifiers for the environments that have archived data.  If this path contains no\ndata, then an empty list is returned.\n"
  },
  "response": [
    {
      "name": "Untitled Example",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/organizations/:organization/environments",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "organizations",
            ":organization",
            "environments"
          ],
          "variable": [
            {
              "key": "organization"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"resources\": [\n  {\n   \"id\": \"proident aute\"\n  },\n  {\n   \"id\": \"in nisi adipisicing enim\"\n  }\n ]\n}"
    },
    {
      "name": "The client is sending more than the allowed number of requests per unit time",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/organizations/:organization/environments",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "organizations",
            ":organization",
            "environments"
          ],
          "variable": [
            {
              "key": "organization"
            }
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "The API service is temporarily unreachable.  Please try again later.  Contact support if problem persists.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/organizations/:organization/environments",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "organizations",
            ":organization",
            "environments"
          ],
          "variable": [
            {
              "key": "organization"
            }
          ]
        }
      },
      "status": "Gateway Timeout",
      "code": 504,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}