PowerBuilder / Postman API / Delete an API
Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Id
// 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
loo_Http.SetRequestHeader("X-API-Key","{{postman_api_key}}")
loo_Resp = loo_Http.QuickRequest("DELETE","https://api.getpostman.com/apis/{{apiId}}")
if loo_Http.LastMethodSuccess = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
return
end if
loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")
loo_Resp.GetBodySb(loo_SbResponseBody)
loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")
loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0
Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()
li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
Write-Debug "Response Header:"
Write-Debug loo_Resp.Header
Write-Debug "Failed."
destroy loo_Resp
destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp
return
end if
destroy loo_Resp
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "api": {
// "id": "387c2863-6ee3-4a56-8210-225f774edade"
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
ls_Id = loo_JResp.StringOf("api.id")
destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp
Curl Command
curl -X DELETE
-H "X-API-Key: {{postman_api_key}}"
https://api.getpostman.com/apis/{{apiId}}
Postman Collection Item JSON
{
"name": "Delete an API",
"request": {
"method": "DELETE",
"header": [
],
"url": {
"raw": "https://api.getpostman.com/apis/{{apiId}}",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"apis",
"{{apiId}}"
]
},
"description": "This call deletes an existing API having the specified id. \n\nResponse contains an `api` object with `id` of the API which was deleted.\n\n> Requires <a href=\"#authentication\">API Key</a> as `X-Api-Key` request header or `apikey` URL query parameter."
},
"response": [
{
"name": "Delete an API",
"originalRequest": {
"method": "DELETE",
"header": [
],
"url": {
"raw": "https://api.getpostman.com/apis/{{apiId}}",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"apis",
"{{apiId}}"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": {
"content": "",
"type": "text/plain"
}
}
],
"cookie": [
],
"body": "{\n\t\"api\": {\n\t\t\"id\": \"387c2863-6ee3-4a56-8210-225f774edade\"\n\t}\n}"
}
]
}