Chilkat Online Tools

unicodeCpp / Zoho CRM REST APIs / Sales Orders

Back to Collection Items

#include <CkHttpW.h>
#include <CkJsonObjectW.h>
#include <CkHttpResponseW.h>

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

    CkHttpW http;
    bool success;

    // 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": [
    //     {
    //       "Status": "Approved"
    //     }
    //   ],
    //   "over_write": true,
    //   "ids": [
    //     "{{record_id1}}",
    //     "{{record_id2}}",
    //     "{{record_id3}}"
    //   ]
    // }

    CkJsonObjectW json;
    json.UpdateString(L"data[0].Status",L"Approved");
    json.UpdateBool(L"over_write",true);
    json.UpdateString(L"ids[0]",L"{{record_id1}}");
    json.UpdateString(L"ids[1]",L"{{record_id2}}");
    json.UpdateString(L"ids[2]",L"{{record_id3}}");

    // Adds the "Authorization: Bearer <access_token>" header.
    http.put_AuthToken(L"<access_token>");

    CkHttpResponseW *resp = http.PostJson3(L"https://domain.com/crm/v2/Sales_Orders/actions/mass_update",L"application/json",json);
    if (http.get_LastMethodSuccess() == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    wprintf(L"%d\n",resp->get_StatusCode());
    wprintf(L"%s\n",resp->bodyStr());
    delete resp;
    }

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-d '{
    "data": [
        {
            "Status": "Approved"
        }
    ],
    "over_write": true,
    "ids": [
        "{{record_id1}}",
        "{{record_id2}}",
        "{{record_id3}}"
    ]
}'
https://domain.com/crm/v2/Sales_Orders/actions/mass_update

Postman Collection Item JSON

{
  "name": "Sales Orders",
  "request": {
    "auth": {
      "type": "bearer",
      "bearer": [
        {
          "key": "token",
          "value": "{{access-token}}",
          "type": "string"
        }
      ]
    },
    "method": "POST",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"data\": [\n        {\n            \"Status\": \"Approved\"\n        }\n    ],\n    \"over_write\": true,\n    \"ids\": [\n        \"{{record_id1}}\",\n        \"{{record_id2}}\",\n        \"{{record_id3}}\"\n    ]\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{api-domain}}/crm/v2/Sales_Orders/actions/mass_update",
      "host": [
        "{{api-domain}}"
      ],
      "path": [
        "crm",
        "v2",
        "Sales_Orders",
        "actions",
        "mass_update"
      ]
    },
    "description": "To schedule mass update for Sales Orders"
  },
  "response": [
  ]
}