Chilkat Online Tools

unicodeC / Zoho CRM REST APIs / Vendors

Back to Collection Items

#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkHttpResponseW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkJsonObjectW json;
    HCkStringBuilderW sbRequestBody;
    HCkHttpResponseW resp;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    http = CkHttpW_Create();

    // 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}}"
    //       },
    //       "Email": "newcrmapi@zoho.com",
    //       "Category": "Category",
    //       "Description": "Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.",
    //       "Vendor_Name": "Vendor_Name",
    //       "Website": "crm.zoho.com",
    //       "City": "City",
    //       "Phone": "988844559",
    //       "State": "State",
    //       "GL_Account": "Rental-Income",
    //       "Street": "Street",
    //       "Country": "Country",
    //       "Zip_Code": "Zip_Code"
    //     }
    //   ]
    // }

    json = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(json,L"data[0].Owner.id",L"{{user-id}}");
    CkJsonObjectW_UpdateString(json,L"data[0].Email",L"newcrmapi@zoho.com");
    CkJsonObjectW_UpdateString(json,L"data[0].Category",L"Category");
    CkJsonObjectW_UpdateString(json,L"data[0].Description",L"Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.");
    CkJsonObjectW_UpdateString(json,L"data[0].Vendor_Name",L"Vendor_Name");
    CkJsonObjectW_UpdateString(json,L"data[0].Website",L"crm.zoho.com");
    CkJsonObjectW_UpdateString(json,L"data[0].City",L"City");
    CkJsonObjectW_UpdateString(json,L"data[0].Phone",L"988844559");
    CkJsonObjectW_UpdateString(json,L"data[0].State",L"State");
    CkJsonObjectW_UpdateString(json,L"data[0].GL_Account",L"Rental-Income");
    CkJsonObjectW_UpdateString(json,L"data[0].Street",L"Street");
    CkJsonObjectW_UpdateString(json,L"data[0].Country",L"Country");
    CkJsonObjectW_UpdateString(json,L"data[0].Zip_Code",L"Zip_Code");

    CkHttpW_SetRequestHeader(http,L"Authorization",L"{{authorization-token}}");
    CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");

    sbRequestBody = CkStringBuilderW_Create();
    CkJsonObjectW_EmitSb(json,sbRequestBody);

    resp = CkHttpW_PTextSb(http,L"PUT",L"https://domain.com/crm/v2.1/Vendors/{{record-id}}",sbRequestBody,L"utf-8",L"application/json",FALSE,FALSE);
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(json);
        CkStringBuilderW_Dispose(sbRequestBody);
        return;
    }

    wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
    wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
    CkHttpResponseW_Dispose(resp);


    CkHttpW_Dispose(http);
    CkJsonObjectW_Dispose(json);
    CkStringBuilderW_Dispose(sbRequestBody);

    }

Curl Command

curl -X PUT
	-H "Authorization: Bearer <access_token>"
	-H "Authorization: {{authorization-token}}"
	-H "Content-Type: application/json"
	-d '{
	"data": [
		{
			"Owner": {
				"id": "{{user-id}}"
			},
			"Email": "newcrmapi@zoho.com",
			"Category": "Category",
			"Description": "Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.",
			"Vendor_Name": "Vendor_Name",
			"Website": "crm.zoho.com",
			"City": "City",
			"Phone": "988844559",
			"State": "State",
			"GL_Account": "Rental-Income",
			"Street": "Street",
			"Country": "Country",
			"Zip_Code": "Zip_Code"
		}
	]
}'
https://domain.com/crm/v2.1/Vendors/{{record-id}}

Postman Collection Item JSON

{
  "name": "Vendors",
  "request": {
    "method": "PUT",
    "header": [
      {
        "key": "Authorization",
        "value": "{{authorization-token}}"
      },
      {
        "key": "Content-Type",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n\t\"data\": [\n\t\t{\n\t\t\t\"Owner\": {\n\t\t\t\t\"id\": \"{{user-id}}\"\n\t\t\t},\n\t\t\t\"Email\": \"newcrmapi@zoho.com\",\n\t\t\t\"Category\": \"Category\",\n\t\t\t\"Description\": \"Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.\",\n\t\t\t\"Vendor_Name\": \"Vendor_Name\",\n\t\t\t\"Website\": \"crm.zoho.com\",\n\t\t\t\"City\": \"City\",\n\t\t\t\"Phone\": \"988844559\",\n\t\t\t\"State\": \"State\",\n\t\t\t\"GL_Account\": \"Rental-Income\",\n\t\t\t\"Street\": \"Street\",\n\t\t\t\"Country\": \"Country\",\n\t\t\t\"Zip_Code\": \"Zip_Code\"\n\t\t}\n\t]\n}"
    },
    "url": {
      "raw": "{{api-domain}}/crm/v2.1/Vendors/{{record-id}}",
      "host": [
        "{{api-domain}}"
      ],
      "path": [
        "crm",
        "v2.1",
        "Vendors",
        "{{record-id}}"
      ]
    },
    "description": "To update existing entities in the module."
  },
  "response": [
  ]
}