SQL Server / New FreshBooks / Delete Business
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
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json'
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequest', @resp OUT, 'DELETE', 'https://api.freshbooks.com/auth/api/v1/users/business/685582'
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
EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
PRINT @iTmp0
EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
END
GO
Curl Command
curl -X DELETE
-H "Authorization: Bearer <access_token>"
-H "Content-Type: application/json"
https://api.freshbooks.com/auth/api/v1/users/business/685582
Postman Collection Item JSON
{
"name": "Delete Business",
"request": {
"method": "DELETE",
"header": [
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
}
],
"url": {
"raw": "https://api.freshbooks.com/auth/api/v1/users/business/685582",
"protocol": "https",
"host": [
"api",
"freshbooks",
"com"
],
"path": [
"auth",
"api",
"v1",
"users",
"business",
"685582"
]
}
},
"response": [
{
"name": "Delete Business",
"originalRequest": {
"method": "DELETE",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"url": {
"raw": "https://my.freshbooks.com/service/api/auth/api/v1/users/business/497510",
"protocol": "https",
"host": [
"my",
"freshbooks",
"com"
],
"path": [
"service",
"api",
"auth",
"api",
"v1",
"users",
"business",
"497510"
]
}
},
"status": "NO CONTENT",
"code": 204,
"_postman_previewlanguage": "html",
"header": [
{
"key": "Server",
"value": "nginx"
},
{
"key": "Content-Type",
"value": "text/html; charset=utf-8"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-Download-Options",
"value": "noopen"
},
{
"key": "X-Permitted-Cross-Domain-Policies",
"value": "none"
},
{
"key": "Referrer-Policy",
"value": "strict-origin-when-cross-origin"
},
{
"key": "Cache-Control",
"value": "no-cache"
},
{
"key": "X-Request-Id",
"value": "2d1d905b-493b-439a-8f4b-3e947c92ee58"
},
{
"key": "X-Runtime",
"value": "0.097614"
},
{
"key": "X-NewRelic-App-Data",
"value": "PxQBWV5TCBABVlVSBAUHUFQTGhEhCQ0WQg1UDl1KG39aAV0NVBZSEAEZZQAFCBdyUxAIDVl1XhUUUEJQClxZMF8XTAtWXw4IYQpMFVQyVhZLVVYNCkEUAx5UTVIZAQ5eUgkHClBQVFAHUAFWAQoYHwJJG1gAVgNXVAYGVgBXDAIIVlBAag=="
},
{
"key": "Access-Control-Allow-Origin",
"value": "*"
},
{
"key": "Expires",
"value": "Wed, 25 Apr 2018 15:46:47 GMT"
},
{
"key": "Via",
"value": "1.1 google"
},
{
"key": "Via",
"value": "1.1 varnish"
},
{
"key": "Accept-Ranges",
"value": "bytes"
},
{
"key": "Date",
"value": "Thu, 25 Apr 2019 15:46:47 GMT"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "X-Served-By",
"value": "cache-mdw17372-MDW"
},
{
"key": "X-Cache",
"value": "MISS"
},
{
"key": "X-Cache-Hits",
"value": "0"
},
{
"key": "Country",
"value": "CA"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=31536000; includeSubDomains; preload"
}
],
"cookie": [
],
"body": null
},
{
"name": "Delete Business - Must Delete Subscription first",
"originalRequest": {
"method": "DELETE",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"url": {
"raw": "https://my.freshbooks.com/service/api/auth/api/v1/users/business/813619",
"protocol": "https",
"host": [
"my",
"freshbooks",
"com"
],
"path": [
"service",
"api",
"auth",
"api",
"v1",
"users",
"business",
"813619"
]
}
},
"status": "UNPROCESSABLE ENTITY",
"code": 422,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "nginx"
},
{
"key": "Content-Type",
"value": "application/json; charset=utf-8"
},
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-Download-Options",
"value": "noopen"
},
{
"key": "X-Permitted-Cross-Domain-Policies",
"value": "none"
},
{
"key": "Referrer-Policy",
"value": "strict-origin-when-cross-origin"
},
{
"key": "Cache-Control",
"value": "no-cache"
},
{
"key": "X-Request-Id",
"value": "0089ca2b-f273-4796-b854-e39734868831"
},
{
"key": "X-Runtime",
"value": "0.082632"
},
{
"key": "X-NewRelic-App-Data",
"value": "PxQBWV5TCBABVlVSBAUHUFQTGhEhCQ0WQg1UDl1KG39aAV0NVBZSEAEZZQAFCBdyUxAIDVl1XhUUUEJQClxZMF8XTAtWXw4IYQpMFVQyVhZLVVYNCkEUAx5UTVIZAQ9VUgkGC1ReUlYIWghRDwkYHwJJG1BVVwVRAgUCV1UHXVdWAgVAag=="
},
{
"key": "Access-Control-Allow-Origin",
"value": "*"
},
{
"key": "Via",
"value": "1.1 google"
},
{
"key": "Via",
"value": "1.1 varnish"
},
{
"key": "Content-Length",
"value": "99"
},
{
"key": "Accept-Ranges",
"value": "bytes"
},
{
"key": "Date",
"value": "Thu, 25 Apr 2019 15:51:10 GMT"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "X-Served-By",
"value": "cache-mdw17372-MDW"
},
{
"key": "X-Cache",
"value": "MISS"
},
{
"key": "X-Cache-Hits",
"value": "0"
},
{
"key": "Country",
"value": "CA"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=31536000; includeSubDomains; preload"
}
],
"cookie": [
],
"body": "{\n \"error\": \"invalid_resource\",\n \"error_description\": \"Validation failed: Subscription is still active.\"\n}"
}
]
}