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 XML: Generate Code to Create XML
-- The following XML is sent in the request body.
-- <?xml version="1.0" encoding="utf-8"?>
-- <supplier-information>
-- <supplier-id>:id</supplier-id>
-- <status>approved</status>
-- <name>SIM Company</name>
-- <exported>true</exported>
-- <supplier-information-addresses>
-- <supplier-information-address>
-- <kind>RTA</kind>
-- <location-code>001</location-code>
-- <street-address>59 Bank Avenue</street-address>
-- <postal-code>15200</postal-code>
-- <city>Pittsburgh</city>
-- <state-region>PA</state-region>
-- <bank-name>Bank Inc.</bank-name>
-- <bank-account-number>9999325</bank-account-number>
-- <currency>
-- <code>USD</code>
-- </currency>
-- </supplier-information-address>
-- <supplier-information-address>
-- <kind>RTA</kind>
-- <location-code>002</location-code>
-- <street-address>71 Sample Street</street-address>
-- <postal-code>19100</postal-code>
-- <city>Philadelphia</city>
-- <state-region>PA</state-region>
-- <bank-name>Cash Co.</bank-name>
-- <bank-account-number>8888325</bank-account-number>
-- <currency>
-- <code>USD</code>
-- </currency>
-- </supplier-information-address>
-- </supplier-information-addresses>
-- </supplier-information>
--
DECLARE @xml int
-- Use "Chilkat_9_5_0.Xml" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Xml', @xml OUT
EXEC sp_OASetProperty @xml, 'Tag', 'supplier-information'
EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'supplier-id', ':id'
EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'status', 'approved'
EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'name', 'SIM Company'
EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'exported', 'true'
EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'supplier-information-addresses|supplier-information-address|kind', 'RTA'
EXEC sp_OAMethod @xml, 'UpdateChildContentInt', NULL, 'supplier-information-addresses|supplier-information-address|location-code', 001
EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'supplier-information-addresses|supplier-information-address|street-address', '59 Bank Avenue'
EXEC sp_OAMethod @xml, 'UpdateChildContentInt', NULL, 'supplier-information-addresses|supplier-information-address|postal-code', 15200
EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'supplier-information-addresses|supplier-information-address|city', 'Pittsburgh'
EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'supplier-information-addresses|supplier-information-address|state-region', 'PA'
EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'supplier-information-addresses|supplier-information-address|bank-name', 'Bank Inc.'
EXEC sp_OAMethod @xml, 'UpdateChildContentInt', NULL, 'supplier-information-addresses|supplier-information-address|bank-account-number', 9999325
EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'supplier-information-addresses|supplier-information-address|currency|code', 'USD'
EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'supplier-information-addresses|supplier-information-address[1]|kind', 'RTA'
EXEC sp_OAMethod @xml, 'UpdateChildContentInt', NULL, 'supplier-information-addresses|supplier-information-address[1]|location-code', 002
EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'supplier-information-addresses|supplier-information-address[1]|street-address', '71 Sample Street'
EXEC sp_OAMethod @xml, 'UpdateChildContentInt', NULL, 'supplier-information-addresses|supplier-information-address[1]|postal-code', 19100
EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'supplier-information-addresses|supplier-information-address[1]|city', 'Philadelphia'
EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'supplier-information-addresses|supplier-information-address[1]|state-region', 'PA'
EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'supplier-information-addresses|supplier-information-address[1]|bank-name', 'Cash Co.'
EXEC sp_OAMethod @xml, 'UpdateChildContentInt', NULL, 'supplier-information-addresses|supplier-information-address[1]|bank-account-number', 8888325
EXEC sp_OAMethod @xml, 'UpdateChildContent', NULL, 'supplier-information-addresses|supplier-information-address[1]|currency|code', 'USD'
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
DECLARE @sbRequestBody int
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbRequestBody OUT
EXEC sp_OAMethod @xml, 'GetXmlSb', @success OUT, @sbRequestBody
DECLARE @resp int
EXEC sp_OAMethod @http, 'PTextSb', @resp OUT, 'POST', 'https://domain.com/supplier_information/', @sbRequestBody, 'utf-8', 'application/xml', 0, 0
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 @xml
EXEC @hr = sp_OADestroy @sbRequestBody
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 @xml
EXEC @hr = sp_OADestroy @sbRequestBody
END
GO
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-d '<supplier-information>
<supplier-id>:id</supplier-id>
<status>approved</status>
<name>SIM Company</name>
<exported>true</exported>
<supplier-information-addresses>
<supplier-information-address>
<kind>RTA</kind>
<location-code>001</location-code>
<street-address>59 Bank Avenue</street-address>
<postal-code>15200</postal-code>
<city>Pittsburgh</city>
<state-region>PA</state-region>
<bank-name>Bank Inc.</bank-name>
<bank-account-number>9999325</bank-account-number>
<currency>
<code>USD</code>
</currency>
</supplier-information-address>
<supplier-information-address>
<kind>RTA</kind>
<location-code>002</location-code>
<street-address>71 Sample Street</street-address>
<postal-code>19100</postal-code>
<city>Philadelphia</city>
<state-region>PA</state-region>
<bank-name>Cash Co.</bank-name>
<bank-account-number>8888325</bank-account-number>
<currency>
<code>USD</code>
</currency>
</supplier-information-address>
</supplier-information-addresses>
</supplier-information>'
https://domain.com/supplier_information/
Postman Collection Item JSON
{
"name": "Create SIM Record against existing Supplier",
"request": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "<supplier-information>\n <supplier-id>:id</supplier-id>\n <status>approved</status>\n <name>SIM Company</name>\n <exported>true</exported>\n <supplier-information-addresses>\n <supplier-information-address>\n <kind>RTA</kind>\n <location-code>001</location-code>\n <street-address>59 Bank Avenue</street-address>\n <postal-code>15200</postal-code>\n <city>Pittsburgh</city>\n <state-region>PA</state-region>\n <bank-name>Bank Inc.</bank-name>\n <bank-account-number>9999325</bank-account-number>\n <currency>\n <code>USD</code>\n </currency>\n </supplier-information-address>\n <supplier-information-address>\n <kind>RTA</kind>\n <location-code>002</location-code>\n <street-address>71 Sample Street</street-address>\n <postal-code>19100</postal-code>\n <city>Philadelphia</city>\n <state-region>PA</state-region>\n <bank-name>Cash Co.</bank-name>\n <bank-account-number>8888325</bank-account-number>\n <currency>\n <code>USD</code>\n </currency>\n </supplier-information-address>\n </supplier-information-addresses>\n</supplier-information>",
"options": {
"raw": {
"language": "xml"
}
}
},
"url": {
"raw": "{{URL}}/supplier_information/",
"host": [
"{{URL}}"
],
"path": [
"supplier_information",
""
]
},
"description": "This API is used for creating shell SIM records before importing legacy Suppliers. Status of SIM will be \"approved\" and exported flag will be marked as true."
},
"response": [
]
}