Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Json
oleobject loo_Resp
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "endpoint": {
// "deploymentType": "CH",
// "isCloudHub": null,
// "muleVersion4OrAbove": null,
// "proxyUri": null,
// "referencesUserDomain": null,
// "responseTimeout": null,
// "type": "raml",
// "uri": null
// },
// "providerId": null,
// "instanceLabel": null,
// "spec": {
// "assetId": "hello-word",
// "groupId": "af696110-60f8-4a47-9367-e2464a468949",
// "version": "0.0.1"
// }
// }
loo_Json = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject")
loo_Json.UpdateString("endpoint.deploymentType","CH")
loo_Json.UpdateNull("endpoint.isCloudHub")
loo_Json.UpdateNull("endpoint.muleVersion4OrAbove")
loo_Json.UpdateNull("endpoint.proxyUri")
loo_Json.UpdateNull("endpoint.referencesUserDomain")
loo_Json.UpdateNull("endpoint.responseTimeout")
loo_Json.UpdateString("endpoint.type","raml")
loo_Json.UpdateNull("endpoint.uri")
loo_Json.UpdateNull("providerId")
loo_Json.UpdateNull("instanceLabel")
loo_Json.UpdateString("spec.assetId","hello-word")
loo_Json.UpdateString("spec.groupId","af696110-60f8-4a47-9367-e2464a468949")
loo_Json.UpdateString("spec.version","0.0.1")
// Adds the "Authorization: Bearer {{token}}" header.
loo_Http.AuthToken = "{{token}}"
loo_Resp = loo_Http.PostJson3("https://domain.com/apimanager/api/v1/organizations/{{organization_id}}/environments/{{environment_id}}/apis","application/json",loo_Json)
if loo_Http.LastMethodSuccess = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_Json
return
end if
Write-Debug string(loo_Resp.StatusCode)
Write-Debug loo_Resp.BodyStr
destroy loo_Resp
destroy loo_Http
destroy loo_Json
Curl Command
curl -X POST
-H "Authorization: Bearer {{token}}"
-d '{
"endpoint":{
"deploymentType":"CH",
"isCloudHub":null,
"muleVersion4OrAbove":null,
"proxyUri":null,
"referencesUserDomain":null,
"responseTimeout":null,
"type":"raml",
"uri":null
},
"providerId":null,
"instanceLabel":null,
"spec":{
"assetId":"hello-word",
"groupId":"af696110-60f8-4a47-9367-e2464a468949",
"version":"0.0.1"
}
}'
https://domain.com/apimanager/api/v1/organizations/{{organization_id}}/environments/{{environment_id}}/apis
Postman Collection Item JSON
{
"name": "Create API from Exchange",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{token}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"endpoint\":{\r\n \"deploymentType\":\"CH\",\r\n \"isCloudHub\":null,\r\n \"muleVersion4OrAbove\":null,\r\n \"proxyUri\":null,\r\n \"referencesUserDomain\":null,\r\n \"responseTimeout\":null,\r\n \"type\":\"raml\",\r\n \"uri\":null\r\n },\r\n \"providerId\":null,\r\n \"instanceLabel\":null,\r\n \"spec\":{\r\n \"assetId\":\"hello-word\",\r\n \"groupId\":\"af696110-60f8-4a47-9367-e2464a468949\",\r\n \"version\":\"0.0.1\"\r\n }\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{url}}/apimanager/api/v1/organizations/{{organization_id}}/environments/{{environment_id}}/apis",
"host": [
"{{url}}"
],
"path": [
"apimanager",
"api",
"v1",
"organizations",
"{{organization_id}}",
"environments",
"{{environment_id}}",
"apis"
]
}
},
"response": [
]
}