DataFlex / Postman API / Delete Environment
Back to Collection Items
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
Boolean iSuccess
Variant vResp
Handle hoResp
Variant vSbResponseBody
Handle hoSbResponseBody
Handle hoJResp
Integer iRespStatusCode
String sId
String sUid
String sTemp1
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
Send ComSetRequestHeader To hoHttp "X-API-Key" "{{postman_api_key}}"
Get ComQuickRequest Of hoHttp "DELETE" "https://api.getpostman.com/environments/{{environment_uid}}" 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 Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess
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 ComStatusCode Of hoResp To iRespStatusCode
Showln "Response Status Code = " iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Header:"
Get ComHeader Of hoResp To sTemp1
Showln sTemp1
Showln "Failed."
Send Destroy of hoResp
Procedure_Return
End
Send Destroy of hoResp
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "environment": {
// "id": "4dfb28a4-9a6c-4ce4-b31a-17c26a8b2cce",
// "uid": "5852-4dfb28a4-9a6c-4ce4-b31a-17c26a8b2cce"
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
Get ComStringOf Of hoJResp "environment.id" To sId
Get ComStringOf Of hoJResp "environment.uid" To sUid
End_Procedure
Curl Command
curl -X DELETE
-H "X-API-Key: {{postman_api_key}}"
https://api.getpostman.com/environments/{{environment_uid}}
Postman Collection Item JSON
{
"name": "Delete Environment",
"request": {
"method": "DELETE",
"header": [
],
"url": {
"raw": "https://api.getpostman.com/environments/{{environment_uid}}",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"environments",
"{{environment_uid}}"
]
},
"description": "This endpoint allows you to delete a single environment based on an environment's unique `uid`.\n\n> Requires <a href=\"#authentication\">API Key</a> as `X-Api-Key` request header or `apikey` URL query parameter."
},
"response": [
{
"name": "Environment Deleted",
"originalRequest": {
"method": "DELETE",
"header": [
],
"url": {
"raw": "https://api.getpostman.com/environments/{{environment_uid}}",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"environments",
"{{environment_uid}}"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"name": "Content-Type",
"description": {
"content": "",
"type": "text/plain"
}
}
],
"cookie": [
],
"body": "{\n \"environment\": {\n \"id\": \"4dfb28a4-9a6c-4ce4-b31a-17c26a8b2cce\",\n \"uid\": \"5852-4dfb28a4-9a6c-4ce4-b31a-17c26a8b2cce\"\n }\n}"
},
{
"name": "Environment Not Found",
"originalRequest": {
"method": "DELETE",
"header": [
],
"url": {
"raw": "https://api.getpostman.com/environments/{{environment_uid}}",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"environments",
"{{environment_uid}}"
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": {
"content": "",
"type": "text/plain"
}
}
],
"cookie": [
],
"body": "{\n \"error\": {\n \"name\": \"instanceNotFoundError\",\n \"message\": \"The specified environment does not exist.\"\n }\n}"
}
]
}