Back to Collection Items
func chilkatTest() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()!
var success: Bool
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "data": [
// {
// "Owner": {
// "id": "{{user-id}}"
// },
// "Handler": {
// "id": "{{user-id}}"
// },
// "Vendor_Name": {
// "id": "{{vendor-id}}"
// },
// "Product_Category": "Software",
// "Qty_in_Demand": 1237.89,
// "Description": "Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.",
// "Commission_Rate": 1237.67,
// "Product_Name": "Product_Name",
// "Quantity_In_Stock": 12792,
// "Sales_Start_Date": "2018-01-25",
// "Tax": [
// "Sales Tax"
// ],
// "Support_Start_Date": "2018-01-25",
// "Product_Active": true,
// "Usage_Unit": "Caton",
// "Product_Code": "Product_Code",
// "Qty_Ordered": 1237.89,
// "Manufacturer": "LexPon Inc.",
// "Qty_in_Stock": 1237.89,
// "Support_Expiry_Date": "2018-01-25",
// "Sales_End_Date": "2018-01-25",
// "Unit_Price": 1237.67,
// "Taxable": true,
// "Reorder_Level": 1237.89
// }
// ]
// }
let json = CkoJsonObject()!
json.update("data[0].Owner.id", value: "{{user-id}}")
json.update("data[0].Handler.id", value: "{{user-id}}")
json.update("data[0].Vendor_Name.id", value: "{{vendor-id}}")
json.update("data[0].Product_Category", value: "Software")
json.updateNumber("data[0].Qty_in_Demand", numericStr: "1237.89")
json.update("data[0].Description", value: "Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.")
json.updateNumber("data[0].Commission_Rate", numericStr: "1237.67")
json.update("data[0].Product_Name", value: "Product_Name")
json.updateInt("data[0].Quantity_In_Stock", value: 12792)
json.update("data[0].Sales_Start_Date", value: "2018-01-25")
json.update("data[0].Tax[0]", value: "Sales Tax")
json.update("data[0].Support_Start_Date", value: "2018-01-25")
json.updateBool("data[0].Product_Active", value: true)
json.update("data[0].Usage_Unit", value: "Caton")
json.update("data[0].Product_Code", value: "Product_Code")
json.updateNumber("data[0].Qty_Ordered", numericStr: "1237.89")
json.update("data[0].Manufacturer", value: "LexPon Inc.")
json.updateNumber("data[0].Qty_in_Stock", numericStr: "1237.89")
json.update("data[0].Support_Expiry_Date", value: "2018-01-25")
json.update("data[0].Sales_End_Date", value: "2018-01-25")
json.updateNumber("data[0].Unit_Price", numericStr: "1237.67")
json.updateBool("data[0].Taxable", value: true)
json.updateNumber("data[0].Reorder_Level", numericStr: "1237.89")
http.setRequestHeader("Authorization", value: "{{authorization-token}}")
http.setRequestHeader("Content-Type", value: "application/json")
var resp: CkoHttpResponse? = http.postJson3("https://domain.com/crm/v2.1/Products", contentType: "application/json", json: json)
if http.lastMethodSuccess == false {
print("\(http.lastErrorText!)")
return
}
print("\(resp!.statusCode.intValue)")
print("\(resp!.bodyStr!)")
resp = nil
}
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-H "Authorization: {{authorization-token}}"
-H "Content-Type: application/json"
-d '{
"data": [
{
"Owner": {
"id": "{{user-id}}"
},
"Handler": {
"id": "{{user-id}}"
},
"Vendor_Name": {
"id": "{{vendor-id}}"
},
"Product_Category": "Software",
"Qty_in_Demand": 1237.89,
"Description": "Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.",
"Commission_Rate": 1237.67,
"Product_Name": "Product_Name",
"Quantity_In_Stock": 12792,
"Sales_Start_Date": "2018-01-25",
"Tax": [
"Sales Tax"
],
"Support_Start_Date": "2018-01-25",
"Product_Active": true,
"Usage_Unit": "Caton",
"Product_Code": "Product_Code",
"Qty_Ordered": 1237.89,
"Manufacturer": "LexPon Inc.",
"Qty_in_Stock": 1237.89,
"Support_Expiry_Date": "2018-01-25",
"Sales_End_Date": "2018-01-25",
"Unit_Price": 1237.67,
"Taxable": true,
"Reorder_Level": 1237.89
}
]
}'
https://domain.com/crm/v2.1/Products
Postman Collection Item JSON
{
"name": "Products",
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "{{authorization-token}}"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"data\": [\n {\n \"Owner\": {\n \"id\": \"{{user-id}}\"\n },\n \"Handler\": {\n \"id\": \"{{user-id}}\"\n },\n \"Vendor_Name\": {\n \"id\": \"{{vendor-id}}\"\n },\n \"Product_Category\": \"Software\",\n \"Qty_in_Demand\": 1237.89,\n \"Description\": \"Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.\",\n \"Commission_Rate\": 1237.67,\n \"Product_Name\": \"Product_Name\",\n \"Quantity_In_Stock\": 12792,\n \"Sales_Start_Date\": \"2018-01-25\",\n \"Tax\": [\n \"Sales Tax\"\n ],\n \"Support_Start_Date\": \"2018-01-25\",\n \"Product_Active\": true,\n \"Usage_Unit\": \"Caton\",\n \"Product_Code\": \"Product_Code\",\n \"Qty_Ordered\": 1237.89,\n \"Manufacturer\": \"LexPon Inc.\",\n \"Qty_in_Stock\": 1237.89,\n \"Support_Expiry_Date\": \"2018-01-25\",\n \"Sales_End_Date\": \"2018-01-25\",\n \"Unit_Price\": 1237.67,\n \"Taxable\": true,\n \"Reorder_Level\": 1237.89\n }\n ]\n}"
},
"url": {
"raw": "{{api-domain}}/crm/v2.1/Products",
"host": [
"{{api-domain}}"
],
"path": [
"crm",
"v2.1",
"Products"
]
},
"description": "To add new entities to a module."
},
"response": [
]
}