SQL Server / Postman API / Delete Monitor
Back to Collection Items
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'X-API-Key', '{{postman_api_key}}'
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequest', @resp OUT, 'DELETE', 'https://api.getpostman.com/monitors/{{monitor_uid}}'
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
RETURN
END
DECLARE @sbResponseBody int
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @resp, 'GetBodySb', @success OUT, @sbResponseBody
DECLARE @jResp int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT
EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
EXEC sp_OASetProperty @jResp, 'EmitCompact', 0
PRINT 'Response Body:'
EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
PRINT @sTmp0
DECLARE @respStatusCode int
EXEC sp_OAGetProperty @resp, 'StatusCode', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @resp, 'Header', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
RETURN
END
EXEC @hr = sp_OADestroy @resp
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- {
-- "monitor": {
-- "id": "1e6b8957-35f9-42a0-8d2f-f03d7085b3d2",
-- "uid": "5852-1e6b8957-35f9-42a0-8d2f-f03d7085b3d2"
-- }
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @Id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Id OUT, 'monitor.id'
DECLARE @Uid nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Uid OUT, 'monitor.uid'
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
Curl Command
curl -X DELETE
-H "X-API-Key: {{postman_api_key}}"
https://api.getpostman.com/monitors/{{monitor_uid}}
Postman Collection Item JSON
{
"name": "Delete Monitor",
"request": {
"method": "DELETE",
"header": [
],
"url": {
"raw": "https://api.getpostman.com/monitors/{{monitor_uid}}",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"monitors",
"{{monitor_uid}}"
]
},
"description": "This endpoint can be used to delete an existing monitor 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": "Monitor Not Found",
"originalRequest": {
"method": "DELETE",
"header": [
],
"url": {
"raw": "https://api.getpostman.com/monitors/{{monitor_uid}}",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"monitors",
"{{monitor_uid}}"
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"name": "Content-Type",
"description": {
"content": "",
"type": "text/plain"
}
}
],
"cookie": [
{
"expires": "Invalid Date",
"hostOnly": false,
"httpOnly": false,
"domain": "getpostman.com",
"path": "/",
"secure": false,
"session": false,
"value": "yes",
"key": "getpostmanlogin"
},
{
"expires": "Invalid Date",
"hostOnly": false,
"httpOnly": false,
"domain": "getpostman.com",
"path": "/",
"secure": false,
"session": false,
"value": "813af79fd620c970d59f4e41275292a96873bb5065975eccf67a84cfdc24b448037430d26c2a29f4192ad492875ed7a0d53bbea8c63f760bb75c886624b4da560fc52c7f9f9e79837bee212f90b9a59c1dfcf94b95156b20f45169eab2ed93b0c38669819143ae41e45dfaac6a5f0cf6d5e76ca40134c3bd9ef9f5532ad6d179519aa0315fe4e6e157ee9d71c9f14aa9b0455ff84f94ae7519f1139d0cccdeeef7e2aafe1696cf640ec874c62d4d5bda3dbe17cf6083fb276b7f3355eb19162430f171166d19a7d79da028c76b3c2b97e88c93dc7183bc486d9d331b93b9a20de1216e84ca74f7b6887df61785d0b65be19f56283523f211fd43a772afa39aadc3b8dc011ba680b69a7e4fcda83be75d593c8ce6c6997bf530b57a8036881ea3d5b3c28d096099ca712f5d6916b453f1b338c455c4f861da638dffd05fd2a3dd5b9dd6dbe5f2c3a30e304363c9c2bcfbe5d9abeba9c06df16d155a70c6b0a9848f7446a5646e58640d7fad642df11350f528e4bacb5c446986cddf8f0c7ad10ec1067daccca962d6fb90aad8db55c2ffa1dc8716865350d5127cb69e44cfc4511836cbc5828c1c01370c7464fef1f07c716456a57a467bc1445ea88b705ef9c0c068948a73dca851804663befbc2d9aec7cfc3a2daf377b1a8c020091216d82504ff9b38c84234ad9b6f8c596a",
"key": "postman.sid"
},
{
"expires": "Invalid Date",
"hostOnly": false,
"httpOnly": false,
"domain": "getpostman.com",
"path": "/",
"secure": false,
"session": false,
"value": "b8ee90dd180562a5a21edad92ea0b987583b7599811884947b9aae88d0c060e8abb0c337534285da6defa4cfabba320b37b611b2c9586b81cb38220830b58440a2ff03756c898b89eb08799bc486c7dc08643ef1ee6e38e5988c4aafda47f1ed26c4218a23620f43d57aa19bb7f79762b394384215a7805e6b1c2cc092b6ac5ad8e8848b1ce655edba6f52820a2ac5acf3d289dda878c6a1fe62e88bb4159f605e8081afa2afce7a72a0c5d96515d566bcbf9cb3842cfc2b7f3a48badbcbfb9e5907b6451674d2c09cf6bf0b34b967edfc3a6389a834f7be21592ba2fbf7aa9eaaa6b87f99590813ded37c6e4ad17e7afcca74455b703d2d653e6ce063ce8eb195ce46c910a1b61fb71f13a8cb52ab2a7bded1b9b5a6b56ad5a66ceafc20afc70962a1f49b8abf2ce3f9e7cf3f44aaf0f41f81605b4ee612f3044d81b787a7cb128c56474a25cdc13803e9057603ead1f1fd6666ae5467ca9e250bb228dfd11dafd16345019bb7e06c58b27bf69d550cbfcef348bc746fdea61d4ea93c48d5f5e4e729adf18655669170f0a059025a79fb2a48f924d9748895a42780d1a9fae32ebf2d57df434c60b675412e217d126b9edbd28b949dfcbcbc8518aa51339d3e1d1f37c6cac4866064c54a476cf94d749a570938a7ad3ce28a9f1c5ea6623b",
"key": "postman-staging.sid"
}
],
"body": "{\n \"error\": {\n \"name\": \"instanceNotFoundError\",\n \"message\": \"The specified monitor does not exist.\"\n }\n}"
},
{
"name": "Monitor Deleted",
"originalRequest": {
"method": "DELETE",
"header": [
],
"url": {
"raw": "https://api.getpostman.com/monitors/{{monitor_uid}}",
"protocol": "https",
"host": [
"api",
"getpostman",
"com"
],
"path": [
"monitors",
"{{monitor_uid}}"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"name": "Content-Type",
"description": {
"content": "",
"type": "text/plain"
}
}
],
"cookie": [
{
"expires": "Invalid Date",
"hostOnly": false,
"httpOnly": false,
"domain": "getpostman.com",
"path": "/",
"secure": false,
"session": false,
"value": "yes",
"key": "getpostmanlogin"
},
{
"expires": "Invalid Date",
"hostOnly": false,
"httpOnly": false,
"domain": "getpostman.com",
"path": "/",
"secure": false,
"session": false,
"value": "813af79fd620c970d59f4e41275292a96873bb5065975eccf67a84cfdc24b448037430d26c2a29f4192ad492875ed7a0d53bbea8c63f760bb75c886624b4da560fc52c7f9f9e79837bee212f90b9a59c1dfcf94b95156b20f45169eab2ed93b0c38669819143ae41e45dfaac6a5f0cf6d5e76ca40134c3bd9ef9f5532ad6d179519aa0315fe4e6e157ee9d71c9f14aa9b0455ff84f94ae7519f1139d0cccdeeef7e2aafe1696cf640ec874c62d4d5bda3dbe17cf6083fb276b7f3355eb19162430f171166d19a7d79da028c76b3c2b97e88c93dc7183bc486d9d331b93b9a20de1216e84ca74f7b6887df61785d0b65be19f56283523f211fd43a772afa39aadc3b8dc011ba680b69a7e4fcda83be75d593c8ce6c6997bf530b57a8036881ea3d5b3c28d096099ca712f5d6916b453f1b338c455c4f861da638dffd05fd2a3dd5b9dd6dbe5f2c3a30e304363c9c2bcfbe5d9abeba9c06df16d155a70c6b0a9848f7446a5646e58640d7fad642df11350f528e4bacb5c446986cddf8f0c7ad10ec1067daccca962d6fb90aad8db55c2ffa1dc8716865350d5127cb69e44cfc4511836cbc5828c1c01370c7464fef1f07c716456a57a467bc1445ea88b705ef9c0c068948a73dca851804663befbc2d9aec7cfc3a2daf377b1a8c020091216d82504ff9b38c84234ad9b6f8c596a",
"key": "postman.sid"
},
{
"expires": "Invalid Date",
"hostOnly": false,
"httpOnly": false,
"domain": "getpostman.com",
"path": "/",
"secure": false,
"session": false,
"value": "b8ee90dd180562a5a21edad92ea0b987583b7599811884947b9aae88d0c060e8abb0c337534285da6defa4cfabba320b37b611b2c9586b81cb38220830b58440a2ff03756c898b89eb08799bc486c7dc08643ef1ee6e38e5988c4aafda47f1ed26c4218a23620f43d57aa19bb7f79762b394384215a7805e6b1c2cc092b6ac5ad8e8848b1ce655edba6f52820a2ac5acf3d289dda878c6a1fe62e88bb4159f605e8081afa2afce7a72a0c5d96515d566bcbf9cb3842cfc2b7f3a48badbcbfb9e5907b6451674d2c09cf6bf0b34b967edfc3a6389a834f7be21592ba2fbf7aa9eaaa6b87f99590813ded37c6e4ad17e7afcca74455b703d2d653e6ce063ce8eb195ce46c910a1b61fb71f13a8cb52ab2a7bded1b9b5a6b56ad5a66ceafc20afc70962a1f49b8abf2ce3f9e7cf3f44aaf0f41f81605b4ee612f3044d81b787a7cb128c56474a25cdc13803e9057603ead1f1fd6666ae5467ca9e250bb228dfd11dafd16345019bb7e06c58b27bf69d550cbfcef348bc746fdea61d4ea93c48d5f5e4e729adf18655669170f0a059025a79fb2a48f924d9748895a42780d1a9fae32ebf2d57df434c60b675412e217d126b9edbd28b949dfcbcbc8518aa51339d3e1d1f37c6cac4866064c54a476cf94d749a570938a7ad3ce28a9f1c5ea6623b",
"key": "postman-staging.sid"
}
],
"body": "{\n \"monitor\": {\n \"id\": \"1e6b8957-35f9-42a0-8d2f-f03d7085b3d2\",\n \"uid\": \"5852-1e6b8957-35f9-42a0-8d2f-f03d7085b3d2\"\n }\n}"
}
]
}