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
-- Use this online tool to generate code from sample JSON: Generate Code to Create JSON
-- The following JSON is sent in the request body.
-- {
-- "add": [
-- {
-- "groupId": "bc6c7bb9-87c7-4220-833b-40509c780dd4",
-- "assetId": "baking-common",
-- "version": "1.0.1"
-- }
-- ],
-- "remove": [
-- {
-- "groupId": "bc6c7bb9-87c7-4220-833b-40509c780dd4",
-- "assetId": "baking-common",
-- "version": "1.0.0"
-- }
-- ]
-- }
DECLARE @json int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'add[0].groupId', 'bc6c7bb9-87c7-4220-833b-40509c780dd4'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'add[0].assetId', 'baking-common'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'add[0].version', '1.0.1'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'remove[0].groupId', 'bc6c7bb9-87c7-4220-833b-40509c780dd4'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'remove[0].assetId', 'baking-common'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'remove[0].version', '1.0.0'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'X-OWNER-ID', '{{owner_id}}'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'X-ANYPNT-ENV-ID', '{{environment-id}}'
-- Adds the "Authorization: Bearer 96b384f7-a6d2-43f9-a14b-652f60048b17" header.
EXEC sp_OASetProperty @http, 'AuthToken', '96b384f7-a6d2-43f9-a14b-652f60048b17'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'X-ANYPNT-ORG-ID', '{{org-id}}'
DECLARE @resp int
EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://domain.com/designcenter/api-designer/projects/{{project_id}}/branches/{{branch_name}}/exchange/dependencies', 'application/json', @json
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
EXEC @hr = sp_OADestroy @json
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
EXEC @hr = sp_OADestroy @json
END
GO
Curl Command
curl -X POST
-H "Authorization: Bearer 96b384f7-a6d2-43f9-a14b-652f60048b17"
-H "X-ANYPNT-ENV-ID: {{environment-id}}"
-H "X-ANYPNT-ORG-ID: {{org-id}}"
-H "Content-Type: application/json"
-H "X-OWNER-ID: {{owner_id}}"
-d '{
"add": [
{
"groupId": "bc6c7bb9-87c7-4220-833b-40509c780dd4",
"assetId": "baking-common",
"version": "1.0.1"
}
],
"remove": [
{
"groupId": "bc6c7bb9-87c7-4220-833b-40509c780dd4",
"assetId": "baking-common",
"version": "1.0.0"
}
]
}'
https://domain.com/designcenter/api-designer/projects/{{project_id}}/branches/{{branch_name}}/exchange/dependencies
Postman Collection Item JSON
{
"name": "Update depency from asset",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var jsonData = pm.response.json();",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer 96b384f7-a6d2-43f9-a14b-652f60048b17"
},
{
"key": "X-ANYPNT-ENV-ID",
"type": "text",
"value": "{{environment-id}}"
},
{
"key": "X-ANYPNT-ORG-ID",
"type": "text",
"value": "{{org-id}}"
},
{
"key": "Content-Type",
"name": "Content-Type",
"type": "text",
"value": "application/json"
},
{
"key": "X-OWNER-ID",
"value": "{{owner_id}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"add\": [\n {\n \"groupId\": \"bc6c7bb9-87c7-4220-833b-40509c780dd4\",\n \"assetId\": \"baking-common\",\n \"version\": \"1.0.1\"\n }\n ],\n \"remove\": [\n {\n \"groupId\": \"bc6c7bb9-87c7-4220-833b-40509c780dd4\",\n \"assetId\": \"baking-common\",\n \"version\": \"1.0.0\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{url}}/designcenter/api-designer/projects/{{project_id}}/branches/{{branch_name}}/exchange/dependencies",
"host": [
"{{url}}"
],
"path": [
"designcenter",
"api-designer",
"projects",
"{{project_id}}",
"branches",
"{{branch_name}}",
"exchange",
"dependencies"
]
}
},
"response": [
]
}