SQL Server / Bond APIs / 1a. create customer
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.
-- {
-- "brand_person_id": "a243e515-626d-45a6-83dc-64be0513383b",
-- "dob": "1925-10-23",
-- "first_name": "James",
-- "middle_name": "William",
-- "last_name": "Bond",
-- "addresses": [
-- {
-- "address_type": "PHYSICAL",
-- "street": "123 Market St",
-- "city": "San Francisco",
-- "state": "CA",
-- "zip_code": "12345-1111",
-- "country": "US",
-- "is_primary": true
-- }
-- ]
-- }
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, 'brand_person_id', 'a243e515-626d-45a6-83dc-64be0513383b'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'dob', '1925-10-23'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'first_name', 'James'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'middle_name', 'William'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'last_name', 'Bond'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'addresses[0].address_type', 'PHYSICAL'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'addresses[0].street', '123 Market St'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'addresses[0].city', 'San Francisco'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'addresses[0].state', 'CA'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'addresses[0].zip_code', '12345-1111'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'addresses[0].country', 'US'
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'addresses[0].is_primary', 1
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Authorization', '{{authorization}}'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Identity', '{{identity}}'
DECLARE @resp int
EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://{{environment}}.bond.tech/api/v0/customers', '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 "Content-Type: application/json"
-H "Authorization: {{authorization}}"
-H "Identity: {{identity}}"
-d '{
"brand_person_id": "a243e515-626d-45a6-83dc-64be0513383b",
"dob": "1925-10-23",
"first_name": "James",
"middle_name":"William",
"last_name": "Bond",
"addresses": [
{
"address_type": "PHYSICAL",
"street": "123 Market St",
"city": "San Francisco",
"state": "CA",
"zip_code": "12345-1111",
"country": "US",
"is_primary": true
}
]
}'
https://{{environment}}.bond.tech/api/v0/customers
Postman Collection Item JSON
{
"name": "1a. create customer",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var jsonData = pm.response.json();",
"pm.collectionVariables.set(\"customer_id\", jsonData.customer_id)"
],
"type": "text/javascript"
}
},
{
"listen": "prerequest",
"script": {
"exec": [
"function uuidv4() {",
" return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {",
" var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);",
" return v.toString(16);",
" });",
"}",
"",
"console.log(uuidv4());",
"pm.globals.set(\"variable_key\", \"variable_value\");"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"type": "text",
"value": "application/json"
},
{
"key": "Authorization",
"type": "text",
"value": "{{authorization}}"
},
{
"key": "Identity",
"type": "text",
"value": "{{identity}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"brand_person_id\": \"a243e515-626d-45a6-83dc-64be0513383b\",\n \"dob\": \"1925-10-23\",\n \"first_name\": \"James\",\n \"middle_name\":\"William\",\n \"last_name\": \"Bond\",\n \"addresses\": [\n {\n \"address_type\": \"PHYSICAL\",\n \"street\": \"123 Market St\",\n \"city\": \"San Francisco\",\n \"state\": \"CA\",\n \"zip_code\": \"12345-1111\",\n \"country\": \"US\",\n \"is_primary\": true\n }\n ]\n}"
},
"url": {
"raw": "https://{{environment}}.bond.tech/api/v0/customers",
"protocol": "https",
"host": [
"{{environment}}",
"bond",
"tech"
],
"path": [
"api",
"v0",
"customers"
]
},
"description": "Add Card financial Core"
},
"response": [
{
"name": "example",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
},
{
"key": "Authorization",
"type": "text",
"value": "{{authorization}}"
},
{
"key": "Identity",
"type": "text",
"value": "{{identity}}"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"brand_person_id\": \"2f55fd85-f411-491e-86a2-558336d6c2a5\",\n \"dob\": \"1992-12-01\",\n \"first_name\": \"Johnny\",\n \"middle_name\":\"William\",\n \"last_name\": \"Carson\",\n \"addresses\": [\n {\n \"address_type\": \"PHYSICAL\",\n \"street\": \"123 Market St\",\n \"city\": \"San Fransico\",\n \"state\": \"CA\",\n \"zip_code\": \"12345-1111\",\n \"country\": \"US\",\n \"is_primary\": true\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{environment}}.bond.tech/api/v0/customers",
"protocol": "https",
"host": [
"{{environment}}",
"bond",
"tech"
],
"path": [
"api",
"v0",
"customers"
]
}
},
"_postman_previewlanguage": null,
"header": null,
"cookie": [
],
"body": null
}
]
}