Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Unicode C++ Web API Examples

Primary Categories

AWS Translate
Activix CRM
Adyen
Amazon MWS
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bluzone
CardConnect
ClickBank
Clickatell
Cloudfare
DocuSign
ETrade
Etsy
Facebook
GeoOp
GetHarvest
Jira
MYOB

Magento
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Okta OAuth/OIDC
OneLogin OIDC
PayPal
Peoplevox
Populi
QuickBooks
SOAP finkok.com
Shippo
Shopify
Stripe
SugarCRM
Trello
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
Xero
eBay
effectconnect

 

 

 

(Unicode C++) SugarCRM Create a Record List

Create a record list in Sugar consisting of a set of ids.

Chilkat C/C++ Library Downloads

MS Visual C/C++

Linux/CentOS C/C++

Alpine Linux C/C++

MAC OS X C/C++

armhf/aarch64 C/C++

C++ Builder

iOS C/C++

Android C/C++

Win Mobile 5.0/Pocket PC 2003

Solaris C/C++

FreeBSD C/C++

OpenBSD C/C++

MinGW C/C++

#include <CkRestW.h>
#include <CkJsonObjectW.h>
#include <CkStringBuilderW.h>

void ChilkatSample(void)
    {
    CkRestW rest;
    bool success;

    success = rest.Connect(L"your.site.domain",443,true,true);
    if (success != true) {
        wprintf(L"%s\n",rest.lastErrorText());
        return;
    }

    rest.AddHeader(L"Cache-Control",L"no-cache");
    rest.AddHeader(L"OAuth-Token",L"<access_token>");

    // The following code creates the JSON request body.
    // The JSON created by this code is shown below.
    CkJsonObjectW jsonReq;
    jsonReq.UpdateString(L"records[0]",L"f16760a4-3a52-f77d-1522-5703ca28925f");
    jsonReq.UpdateString(L"records[1]",L"ec409fbb-2b22-4f32-7fa1-5703caf78dc3");

    // The JSON request body created by the above code:

    // {
    //   "records": [
    //     "f16760a4-3a52-f77d-1522-5703ca28925f",
    //     "ec409fbb-2b22-4f32-7fa1-5703caf78dc3"
    //   ]
    // }

    CkStringBuilderW sbReq;
    jsonReq.EmitSb(sbReq);

    rest.AddHeader(L"Content-Type",L"application/json");

    CkStringBuilderW sbJson;
    success = rest.FullRequestSb(L"POST",L"/rest/v10/Accounts/record_list",sbReq,sbJson);
    if (success != true) {
        wprintf(L"%s\n",rest.lastErrorText());
        return;
    }

    if (rest.get_ResponseStatusCode() != 200) {
        wprintf(L"Received error response code: %d\n",rest.get_ResponseStatusCode());
        wprintf(L"Response body:\n");
        wprintf(L"%s\n",sbJson.getAsString());
        return;
    }

    CkJsonObjectW json;
    json.LoadSb(sbJson);

    // The following code parses the JSON response.
    // A sample JSON response is shown below the sample code.
    const wchar_t *id = 0;
    const wchar_t *assigned_user_id = 0;
    const wchar_t *module_name = 0;
    const wchar_t *date_modified = 0;
    int i;
    int count_i;
    const wchar_t *strVal = 0;

    id = json.stringOf(L"id");
    assigned_user_id = json.stringOf(L"assigned_user_id");
    module_name = json.stringOf(L"module_name");
    date_modified = json.stringOf(L"date_modified");
    i = 0;
    count_i = json.SizeOfArray(L"records");
    while (i < count_i) {
        json.put_I(i);
        strVal = json.stringOf(L"records[i]");
        i = i + 1;
    }

    // A sample JSON response body that is parsed by the above code:

    // {
    //   "id": "ef963176-4845-bc55-b03e-570430b4173c",
    //   "assigned_user_id": "1",
    //   "module_name": "Accounts",
    //   "records": [
    //     "f16760a4-3a52-f77d-1522-5703ca28925f",
    //     "ec409fbb-2b22-4f32-7fa1-5703caf78dc3"
    //   ],
    //   "date_modified": "2016-04-05 21:39:19"
    // }

    wprintf(L"Example Completed.\n");
    }

 

© 2000-2019 Chilkat Software, Inc. All Rights Reserved.