Chilkat Online Tools

PureBasic / Anypoint Platform APIs / Get all assets for organization by mulesoft

Back to Collection Items

IncludeFile "CkJsonObject.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"

Procedure ChilkatExample()

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

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success.i

    queryParams.i = CkJsonObject::ckCreate()
    If queryParams.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckUpdateString(queryParams,"search","")
    CkJsonObject::ckUpdateString(queryParams,"types","api-group")
    CkJsonObject::ckUpdateString(queryParams,"types","connector")
    CkJsonObject::ckUpdateString(queryParams,"types","custom")
    CkJsonObject::ckUpdateString(queryParams,"types","example")
    CkJsonObject::ckUpdateString(queryParams,"types","extension")
    CkJsonObject::ckUpdateString(queryParams,"types","http-api")
    CkJsonObject::ckUpdateString(queryParams,"types","policy")
    CkJsonObject::ckUpdateString(queryParams,"types","raml-fragment")
    CkJsonObject::ckUpdateString(queryParams,"types","rest-api")
    CkJsonObject::ckUpdateString(queryParams,"types","soap-api")
    CkJsonObject::ckUpdateString(queryParams,"types","template")
    CkJsonObject::ckUpdateString(queryParams,"domain","")
    CkJsonObject::ckUpdateString(queryParams,"organizationId","{{mulesoft_org_id}}")
    CkJsonObject::ckUpdateString(queryParams,"masterOrganizationId","")
    CkJsonObject::ckUpdateInt(queryParams,"offset",0)
    CkJsonObject::ckUpdateInt(queryParams,"limit",20)
    CkJsonObject::ckUpdateString(queryParams,"sharedWithMe","")
    CkJsonObject::ckUpdateString(queryParams,"includeSnapshots","true")

    ; Adds the "Authorization: Bearer {{token}}" header.
    CkHttp::setCkAuthToken(http, "{{token}}")

    resp.i = CkHttp::ckQuickRequestParams(http,"GET","https://domain.com/exchange/api/v2/assets",queryParams)
    If CkHttp::ckLastMethodSuccess(http) = 0
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        CkJsonObject::ckDispose(queryParams)
        ProcedureReturn
    EndIf

    Debug Str(CkHttpResponse::ckStatusCode(resp))
    Debug CkHttpResponse::ckBodyStr(resp)
    CkHttpResponse::ckDispose(resp)



    CkHttp::ckDispose(http)
    CkJsonObject::ckDispose(queryParams)


    ProcedureReturn
EndProcedure

Curl Command

curl -G -d "search="
	-d "types=api-group"
	-d "types=connector"
	-d "types=custom"
	-d "types=example"
	-d "types=extension"
	-d "types=http-api"
	-d "types=policy"
	-d "types=raml-fragment"
	-d "types=rest-api"
	-d "types=soap-api"
	-d "types=template"
	-d "domain="
	-d "organizationId=%7B%7Bmulesoft_org_id%7D%7D"
	-d "masterOrganizationId="
	-d "offset=0"
	-d "limit=20"
	-d "sharedWithMe="
	-d "includeSnapshots=true"
	-H "Authorization: Bearer {{token}}"
https://domain.com/exchange/api/v2/assets

Postman Collection Item JSON

{
  "name": "Get all assets for organization by mulesoft",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Authorization",
        "value": "Bearer {{token}}",
        "type": "text"
      }
    ],
    "url": {
      "raw": "{{url}}/exchange/api/v2/assets?search=&types=api-group&types=connector&types=custom&types=example&types=extension&types=http-api&types=policy&types=raml-fragment&types=rest-api&types=soap-api&types=template&domain=&organizationId={{mulesoft_org_id}}&masterOrganizationId=&offset=0&limit=20&sharedWithMe=&includeSnapshots=true",
      "host": [
        "{{url}}"
      ],
      "path": [
        "exchange",
        "api",
        "v2",
        "assets"
      ],
      "query": [
        {
          "key": "search",
          "value": ""
        },
        {
          "key": "types",
          "value": "api-group"
        },
        {
          "key": "types",
          "value": "connector"
        },
        {
          "key": "types",
          "value": "custom"
        },
        {
          "key": "types",
          "value": "example"
        },
        {
          "key": "types",
          "value": "extension"
        },
        {
          "key": "types",
          "value": "http-api"
        },
        {
          "key": "types",
          "value": "policy"
        },
        {
          "key": "types",
          "value": "raml-fragment"
        },
        {
          "key": "types",
          "value": "rest-api"
        },
        {
          "key": "types",
          "value": "soap-api"
        },
        {
          "key": "types",
          "value": "template"
        },
        {
          "key": "domain",
          "value": ""
        },
        {
          "key": "organizationId",
          "value": "{{mulesoft_org_id}}"
        },
        {
          "key": "masterOrganizationId",
          "value": ""
        },
        {
          "key": "offset",
          "value": "0"
        },
        {
          "key": "limit",
          "value": "20"
        },
        {
          "key": "sharedWithMe",
          "value": ""
        },
        {
          "key": "includeSnapshots",
          "value": "true"
        }
      ]
    }
  },
  "response": [
  ]
}