Chilkat Online Tools

DataFlex / Anypoint Platform APIs / Add dependency to asset

Back to Collection Items

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vJson
    Handle hoJson
    Variant vResp
    Handle hoResp
    String sTemp1
    Integer iTemp1
    Boolean bTemp1

    // 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

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "add": [
    //     {
    //       "groupId": "bc6c7bb9-87c7-4220-833b-40509c780dd4",
    //       "assetId": "banking-user",
    //       "version": "1.0.1"
    //     }
    //   ],
    //   "remove": [
    //   ]
    // }

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "add[0].groupId" "bc6c7bb9-87c7-4220-833b-40509c780dd4" To iSuccess
    Get ComUpdateString Of hoJson "add[0].assetId" "banking-user" To iSuccess
    Get ComUpdateString Of hoJson "add[0].version" "1.0.1" To iSuccess
    Get ComUpdateNewArray Of hoJson "remove" To iSuccess

    Send ComSetRequestHeader To hoHttp "X-OWNER-ID" "{{owner_id}}"
    Send ComSetRequestHeader To hoHttp "X-ANYPNT-ENV-ID" "{{environment-id}}"
    // Adds the "Authorization: Bearer 96b384f7-a6d2-43f9-a14b-652f60048b17" header.
    Set ComAuthToken Of hoHttp To "96b384f7-a6d2-43f9-a14b-652f60048b17"
    Send ComSetRequestHeader To hoHttp "Content-Type" "application/json"
    Send ComSetRequestHeader To hoHttp "X-ANYPNT-ORG-ID" "{{org-id}}"

    Get pvComObject of hoJson to vJson
    Get ComPostJson3 Of hoHttp "https://domain.com/designcenter/api-designer/projects/{{project_id}}/branches/{{branch_name}}/exchange/dependencies" "application/json" vJson To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComStatusCode Of hoResp To iTemp1
    Showln iTemp1
    Get ComBodyStr Of hoResp To sTemp1
    Showln sTemp1
    Send Destroy of hoResp


End_Procedure

Curl Command

curl -X POST
	-H "Authorization: Bearer 96b384f7-a6d2-43f9-a14b-652f60048b17"
	-H "X-ANYPNT-ENV-ID: {{environment-id}}"
	-H "X-ANYPNT-ORG-ID: {{org-id}}"
	-H "Content-Type: application/json"
	-H "X-OWNER-ID: {{owner_id}}"
	-d '{
    "add": [
        {
            "groupId": "bc6c7bb9-87c7-4220-833b-40509c780dd4",
            "assetId": "banking-user",
            "version": "1.0.1"
        }
    ],
    "remove": []
}'
https://domain.com/designcenter/api-designer/projects/{{project_id}}/branches/{{branch_name}}/exchange/dependencies

Postman Collection Item JSON

{
  "name": "Add dependency to asset",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          "var jsonData = pm.response.json();",
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Authorization",
        "value": "Bearer 96b384f7-a6d2-43f9-a14b-652f60048b17"
      },
      {
        "key": "X-ANYPNT-ENV-ID",
        "type": "text",
        "value": "{{environment-id}}"
      },
      {
        "key": "X-ANYPNT-ORG-ID",
        "type": "text",
        "value": "{{org-id}}"
      },
      {
        "key": "Content-Type",
        "name": "Content-Type",
        "type": "text",
        "value": "application/json"
      },
      {
        "key": "X-OWNER-ID",
        "value": "{{owner_id}}",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"add\": [\n        {\n            \"groupId\": \"bc6c7bb9-87c7-4220-833b-40509c780dd4\",\n            \"assetId\": \"banking-user\",\n            \"version\": \"1.0.1\"\n        }\n    ],\n    \"remove\": []\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{url}}/designcenter/api-designer/projects/{{project_id}}/branches/{{branch_name}}/exchange/dependencies",
      "host": [
        "{{url}}"
      ],
      "path": [
        "designcenter",
        "api-designer",
        "projects",
        "{{project_id}}",
        "branches",
        "{{branch_name}}",
        "exchange",
        "dependencies"
      ]
    }
  },
  "response": [
  ]
}