DataFlex / Postman API / Unpublish Mock
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 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/mocks/{{mock_uid}}/unpublish" 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)
// {
// "mock": {
// "id": "06040138-dd6b-4cce-9a02-7e1c1ab59723"
// }
// }
// 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 "mock.id" To sId
End_Procedure
Curl Command
curl -X DELETE
-H "X-API-Key: {{postman_api_key}}"
https://api.getpostman.com/mocks/{{mock_uid}}/unpublish
Postman Collection Item JSON
{
"name": "Unpublish Mock",
"request": {
"method": "DELETE",
"header": [
],
"url": {
"raw": "https://api.getpostman.com/mocks/{{mock_uid}}/unpublish",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"mocks",
"{{mock_uid}}",
"unpublish"
]
},
"description": "This endpoint unpublishes the mock you have created using its `uid`\n\n> Requires <a href=\"#authentication\">API Key</a> as `X-Api-Key ` request header or `apikey` URL query parameter."
},
"response": [
{
"name": "Success Response",
"originalRequest": {
"method": "DELETE",
"header": [
],
"url": {
"raw": "https://api.getpostman.com/mocks/{{mock_uid}}/unpublish",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"mocks",
"{{mock_uid}}",
"unpublish"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"description": {
"content": "",
"type": "text/plain"
}
}
],
"cookie": [
],
"body": "{\n \"mock\": {\n \"id\": \"06040138-dd6b-4cce-9a02-7e1c1ab59723\"\n }\n}"
}
]
}