Sample code for 30+ languages & platforms
Unicode C++

Yousign: Making your first API call

See more Yousign Examples

Demonstrates making the simplest of calls to test your API key. This example tests using the sandbox URLs.

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkHttpW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.h>

void ChilkatSample(void)
    {
    bool success = false;

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

    CkHttpW http;

    //  Implements the following CURL command:

    //  curl --location --request GET 'https://staging-api.yousign.com/users' \
    //  --header 'Authorization: Bearer YOUR_API_KEY' \
    //  --header 'Content-Type: application/json'

    //  Use the following online tool to generate HTTP code from a CURL command
    //  Convert a cURL Command to HTTP Source Code

    //  Adds the "Authorization: Bearer YOUR_API_KEY" header.
    http.put_AuthToken(L"YOUR_API_KEY");
    http.SetRequestHeader(L"Content-Type",L"application/json");

    CkStringBuilderW sbResponseBody;
    success = http.QuickGetSb(L"https://staging-api.yousign.com/users",sbResponseBody);
    if (success == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    CkJsonObjectW jResp;
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    wprintf(L"Response Body:\n");
    wprintf(L"%s\n",jResp.emit());

    int respStatusCode = http.get_LastStatus();
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",http.lastHeader());
        wprintf(L"Failed.\n");
        return;
    }

    //  Sample JSON response:
    //  (Sample code for parsing the JSON response is shown below)

    //  {
    //    "id": "/users/XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    //    "firstname": "John",
    //    "lastname": "Doe",
    //    "email": "john.doe@yousign.fr",
    //    "title": "Developer",
    //    "phone": "+33612345678",
    //    "status": "activated",
    //    "organization": "/organizations/XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    //    "workspaces": [
    //      {
    //        "id": "/workspaces/XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    //        "name": "Acme"
    //      }
    //    ],
    //    "permission": "ROLE_ADMIN",
    //    "group": {
    //      "id": "/user_groups/XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
    //      "name": "Administrateur",
    //      "permissions": [
    //        "procedure_write",
    //        "procedure_template_write",
    //        "procedure_create_from_template",
    //        "contact",
    //        "sign",
    //        "organization",
    //        "user",
    //        "api_key",
    //        "procedure_custom_field",
    //        "signature_ui",
    //        "certificate",
    //        "archive"
    //      ]
    //    },
    //    "createdAt": "2018-12-01T09:42:25+01:00",
    //    "updatedAt": "2018-12-01T09:42:25+01:00",
    //    "deleted": false,
    //    "deletedAt": null,
    //    "config": [
    //    ],
    //    "inweboUserRequest": null,
    //    "samlNameId": null,
    //    "defaultSignImage": null,
    //    "notifications": {
    //      "procedure": true
    //    },
    //    "fastSign": false,
    //    "fullName": "John Doe"
    //  }

    //  Sample code for parsing the JSON response...
    //  Use the following online tool to generate parsing code from sample JSON:
    //  Generate Parsing Code from JSON

    //  Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
    //  See this example explaining how this memory should be used: const char * functions.

    const wchar_t *name = 0;
    const wchar_t *strVal = 0;

    const wchar_t *id = jResp.stringOf(L"id");
    const wchar_t *firstname = jResp.stringOf(L"firstname");
    const wchar_t *lastname = jResp.stringOf(L"lastname");
    const wchar_t *email = jResp.stringOf(L"email");
    const wchar_t *title = jResp.stringOf(L"title");
    const wchar_t *phone = jResp.stringOf(L"phone");
    const wchar_t *status = jResp.stringOf(L"status");
    const wchar_t *organization = jResp.stringOf(L"organization");
    const wchar_t *permission = jResp.stringOf(L"permission");
    const wchar_t *groupId = jResp.stringOf(L"group.id");
    const wchar_t *groupName = jResp.stringOf(L"group.name");
    const wchar_t *createdAt = jResp.stringOf(L"createdAt");
    const wchar_t *updatedAt = jResp.stringOf(L"updatedAt");
    bool deleted = jResp.BoolOf(L"deleted");
    const wchar_t *deletedAt = jResp.stringOf(L"deletedAt");
    const wchar_t *inweboUserRequest = jResp.stringOf(L"inweboUserRequest");
    const wchar_t *samlNameId = jResp.stringOf(L"samlNameId");
    const wchar_t *defaultSignImage = jResp.stringOf(L"defaultSignImage");
    bool notificationsProcedure = jResp.BoolOf(L"notifications.procedure");
    bool fastSign = jResp.BoolOf(L"fastSign");
    const wchar_t *fullName = jResp.stringOf(L"fullName");
    int i = 0;
    int count_i = jResp.SizeOfArray(L"workspaces");
    while (i < count_i) {
        jResp.put_I(i);
        id = jResp.stringOf(L"workspaces[i].id");
        name = jResp.stringOf(L"workspaces[i].name");
        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray(L"group.permissions");
    while (i < count_i) {
        jResp.put_I(i);
        strVal = jResp.stringOf(L"group.permissions[i]");
        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray(L"config");
    while (i < count_i) {
        jResp.put_I(i);
        i = i + 1;
    }
    }