Chilkat Online Tools

unicodeC / Fatture in Cloud API v2 - API Reference / Modify Supplier

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;
    HCkStringBuilderW sbResponseBody;
    HCkJsonObjectW jResp;
    int respStatusCode;
    const wchar_t *Id;
    const wchar_t *Code;
    const wchar_t *Name;
    const wchar_t *v_Type;
    const wchar_t *First_name;
    const wchar_t *Last_name;
    const wchar_t *Contact_person;
    const wchar_t *Vat_number;
    const wchar_t *Tax_code;
    const wchar_t *Address_street;
    const wchar_t *Address_postal_code;
    const wchar_t *Address_city;
    const wchar_t *Address_province;
    const wchar_t *Address_extra;
    const wchar_t *Country;
    const wchar_t *v_Email;
    const wchar_t *Certified_email;
    const wchar_t *Phone;
    const wchar_t *Fax;
    const wchar_t *Notes;
    const wchar_t *Bank_iban;
    const wchar_t *Created_at;
    const wchar_t *Updated_at;

    // 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": {
    //     "name": "<string>",
    //     "id": "<integer>",
    //     "code": "<string>",
    //     "type": null,
    //     "first_name": "<string>",
    //     "last_name": "<string>",
    //     "contact_person": "<string>",
    //     "vat_number": "<string>",
    //     "tax_code": "<string>",
    //     "address_street": "<string>",
    //     "address_postal_code": "<string>",
    //     "address_city": "<string>",
    //     "address_province": "<string>",
    //     "address_extra": "<string>",
    //     "country": "Italia",
    //     "email": "<string>",
    //     "certified_email": "<string>",
    //     "phone": "<string>",
    //     "fax": "<string>",
    //     "notes": "<string>",
    //     "bank_iban": "<string>",
    //     "created_at": "<string>",
    //     "updated_at": "<string>"
    //   }
    // }

    json = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(json,L"data.name",L"<string>");
    CkJsonObjectW_UpdateString(json,L"data.id",L"<integer>");
    CkJsonObjectW_UpdateString(json,L"data.code",L"<string>");
    CkJsonObjectW_UpdateNull(json,L"data.type");
    CkJsonObjectW_UpdateString(json,L"data.first_name",L"<string>");
    CkJsonObjectW_UpdateString(json,L"data.last_name",L"<string>");
    CkJsonObjectW_UpdateString(json,L"data.contact_person",L"<string>");
    CkJsonObjectW_UpdateString(json,L"data.vat_number",L"<string>");
    CkJsonObjectW_UpdateString(json,L"data.tax_code",L"<string>");
    CkJsonObjectW_UpdateString(json,L"data.address_street",L"<string>");
    CkJsonObjectW_UpdateString(json,L"data.address_postal_code",L"<string>");
    CkJsonObjectW_UpdateString(json,L"data.address_city",L"<string>");
    CkJsonObjectW_UpdateString(json,L"data.address_province",L"<string>");
    CkJsonObjectW_UpdateString(json,L"data.address_extra",L"<string>");
    CkJsonObjectW_UpdateString(json,L"data.country",L"Italia");
    CkJsonObjectW_UpdateString(json,L"data.email",L"<string>");
    CkJsonObjectW_UpdateString(json,L"data.certified_email",L"<string>");
    CkJsonObjectW_UpdateString(json,L"data.phone",L"<string>");
    CkJsonObjectW_UpdateString(json,L"data.fax",L"<string>");
    CkJsonObjectW_UpdateString(json,L"data.notes",L"<string>");
    CkJsonObjectW_UpdateString(json,L"data.bank_iban",L"<string>");
    CkJsonObjectW_UpdateString(json,L"data.created_at",L"<string>");
    CkJsonObjectW_UpdateString(json,L"data.updated_at",L"<string>");

    CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");
    // Adds the "Authorization: Bearer <access_token>" header.
    CkHttpW_putAuthToken(http,L"<access_token>");
    CkHttpW_SetRequestHeader(http,L"Accept",L"application/json");

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

    resp = CkHttpW_PTextSb(http,L"PUT",L"https://api-v2.fattureincloud.it/c/:company_id/entities/suppliers/:supplier_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;
    }

    sbResponseBody = CkStringBuilderW_Create();
    CkHttpResponseW_GetBodySb(resp,sbResponseBody);

    jResp = CkJsonObjectW_Create();
    CkJsonObjectW_LoadSb(jResp,sbResponseBody);
    CkJsonObjectW_putEmitCompact(jResp,FALSE);

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

    respStatusCode = CkHttpResponseW_getStatusCode(resp);
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",CkHttpResponseW_header(resp));
        wprintf(L"Failed.\n");
        CkHttpResponseW_Dispose(resp);
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(json);
        CkStringBuilderW_Dispose(sbRequestBody);
        CkStringBuilderW_Dispose(sbResponseBody);
        CkJsonObjectW_Dispose(jResp);
        return;
    }

    CkHttpResponseW_Dispose(resp);

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

    // {
    //   "data": {
    //     "id": "<integer>",
    //     "code": "<string>",
    //     "name": "<string>",
    //     "type": null,
    //     "first_name": "<string>",
    //     "last_name": "<string>",
    //     "contact_person": "<string>",
    //     "vat_number": "<string>",
    //     "tax_code": "<string>",
    //     "address_street": "<string>",
    //     "address_postal_code": "<string>",
    //     "address_city": "<string>",
    //     "address_province": "<string>",
    //     "address_extra": "<string>",
    //     "country": "<string>",
    //     "email": "<string>",
    //     "certified_email": "<string>",
    //     "phone": "<string>",
    //     "fax": "<string>",
    //     "notes": "<string>",
    //     "bank_iban": "<string>",
    //     "created_at": "<string>",
    //     "updated_at": "<string>"
    //   }
    // }

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

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.

    Id = CkJsonObjectW_stringOf(jResp,L"data.id");
    Code = CkJsonObjectW_stringOf(jResp,L"data.code");
    Name = CkJsonObjectW_stringOf(jResp,L"data.name");
    v_Type = CkJsonObjectW_stringOf(jResp,L"data.type");
    First_name = CkJsonObjectW_stringOf(jResp,L"data.first_name");
    Last_name = CkJsonObjectW_stringOf(jResp,L"data.last_name");
    Contact_person = CkJsonObjectW_stringOf(jResp,L"data.contact_person");
    Vat_number = CkJsonObjectW_stringOf(jResp,L"data.vat_number");
    Tax_code = CkJsonObjectW_stringOf(jResp,L"data.tax_code");
    Address_street = CkJsonObjectW_stringOf(jResp,L"data.address_street");
    Address_postal_code = CkJsonObjectW_stringOf(jResp,L"data.address_postal_code");
    Address_city = CkJsonObjectW_stringOf(jResp,L"data.address_city");
    Address_province = CkJsonObjectW_stringOf(jResp,L"data.address_province");
    Address_extra = CkJsonObjectW_stringOf(jResp,L"data.address_extra");
    Country = CkJsonObjectW_stringOf(jResp,L"data.country");
    v_Email = CkJsonObjectW_stringOf(jResp,L"data.email");
    Certified_email = CkJsonObjectW_stringOf(jResp,L"data.certified_email");
    Phone = CkJsonObjectW_stringOf(jResp,L"data.phone");
    Fax = CkJsonObjectW_stringOf(jResp,L"data.fax");
    Notes = CkJsonObjectW_stringOf(jResp,L"data.notes");
    Bank_iban = CkJsonObjectW_stringOf(jResp,L"data.bank_iban");
    Created_at = CkJsonObjectW_stringOf(jResp,L"data.created_at");
    Updated_at = CkJsonObjectW_stringOf(jResp,L"data.updated_at");


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

    }

Curl Command

curl -X PUT
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: application/json"
	-H "Accept: application/json"
	-d '{
  "data": {
    "name": "<string>",
    "id": "<integer>",
    "code": "<string>",
    "type": null,
    "first_name": "<string>",
    "last_name": "<string>",
    "contact_person": "<string>",
    "vat_number": "<string>",
    "tax_code": "<string>",
    "address_street": "<string>",
    "address_postal_code": "<string>",
    "address_city": "<string>",
    "address_province": "<string>",
    "address_extra": "<string>",
    "country": "Italia",
    "email": "<string>",
    "certified_email": "<string>",
    "phone": "<string>",
    "fax": "<string>",
    "notes": "<string>",
    "bank_iban": "<string>",
    "created_at": "<string>",
    "updated_at": "<string>"
  }
}'
https://api-v2.fattureincloud.it/c/:company_id/entities/suppliers/:supplier_id

Postman Collection Item JSON

{
  "name": "Modify Supplier",
  "request": {
    "auth": {
      "type": "oauth2",
      "oauth2": [
        {
          "key": "scope",
          "value": "entity.clients:r entity.clients:a entity.suppliers:r entity.suppliers:a products:r products:a issued_documents.invoices:r issued_documents.credit_notes:r issued_documents.receipts:r issued_documents.orders:r issued_documents.quotes:r issued_documents.proformas:r issued_documents.delivery_notes:r issued_documents.work_reports:r issued_documents.supplier_orders:r issued_documents.self_invoices:r issued_documents.invoices:a issued_documents.credit_notes:a issued_documents.receipts:a issued_documents.orders:a issued_documents.quotes:a issued_documents.proformas:a issued_documents.delivery_notes:a issued_documents.work_reports:a issued_documents.supplier_orders:a issued_documents.self_invoices:a received_documents:r received_documents:a stock:r stock:a receipts:r receipts:a taxes:r taxes:a archive:r archive:a cashbook:r cashbook:a settings:r settings:a situation:r",
          "type": "string"
        },
        {
          "key": "redirect_uri",
          "value": "https://api-v2.fattureincloud.it/oauth/token",
          "type": "string"
        },
        {
          "key": "accessTokenUrl",
          "value": "https://api-v2.fattureincloud.it/oauth/token",
          "type": "string"
        },
        {
          "key": "authUrl",
          "value": "https://api-v2.fattureincloud.it/oauth/authorize",
          "type": "string"
        },
        {
          "key": "grant_type",
          "value": "authorization_code",
          "type": "string"
        }
      ]
    },
    "method": "PUT",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      },
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n  \"data\": {\n    \"name\": \"<string>\",\n    \"id\": \"<integer>\",\n    \"code\": \"<string>\",\n    \"type\": null,\n    \"first_name\": \"<string>\",\n    \"last_name\": \"<string>\",\n    \"contact_person\": \"<string>\",\n    \"vat_number\": \"<string>\",\n    \"tax_code\": \"<string>\",\n    \"address_street\": \"<string>\",\n    \"address_postal_code\": \"<string>\",\n    \"address_city\": \"<string>\",\n    \"address_province\": \"<string>\",\n    \"address_extra\": \"<string>\",\n    \"country\": \"Italia\",\n    \"email\": \"<string>\",\n    \"certified_email\": \"<string>\",\n    \"phone\": \"<string>\",\n    \"fax\": \"<string>\",\n    \"notes\": \"<string>\",\n    \"bank_iban\": \"<string>\",\n    \"created_at\": \"<string>\",\n    \"updated_at\": \"<string>\"\n  }\n}",
      "options": {
        "raw": {
          "headerFamily": "json",
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{baseUrl}}/c/:company_id/entities/suppliers/:supplier_id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "c",
        ":company_id",
        "entities",
        "suppliers",
        ":supplier_id"
      ],
      "variable": [
        {
          "key": "company_id",
          "value": "<integer>"
        },
        {
          "key": "supplier_id",
          "value": "<integer>"
        }
      ]
    },
    "description": "Modifies the specified supplier."
  },
  "response": [
    {
      "name": "Example response",
      "originalRequest": {
        "method": "PUT",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"data\": {\n    \"name\": \"<string>\",\n    \"id\": \"<integer>\",\n    \"code\": \"<string>\",\n    \"type\": null,\n    \"first_name\": \"<string>\",\n    \"last_name\": \"<string>\",\n    \"contact_person\": \"<string>\",\n    \"vat_number\": \"<string>\",\n    \"tax_code\": \"<string>\",\n    \"address_street\": \"<string>\",\n    \"address_postal_code\": \"<string>\",\n    \"address_city\": \"<string>\",\n    \"address_province\": \"<string>\",\n    \"address_extra\": \"<string>\",\n    \"country\": \"Italia\",\n    \"email\": \"<string>\",\n    \"certified_email\": \"<string>\",\n    \"phone\": \"<string>\",\n    \"fax\": \"<string>\",\n    \"notes\": \"<string>\",\n    \"bank_iban\": \"<string>\",\n    \"created_at\": \"<string>\",\n    \"updated_at\": \"<string>\"\n  }\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/c/:company_id/entities/suppliers/:supplier_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "c",
            ":company_id",
            "entities",
            "suppliers",
            ":supplier_id"
          ],
          "variable": [
            {
              "key": "company_id"
            },
            {
              "key": "supplier_id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"data\": {\n    \"id\": \"<integer>\",\n    \"code\": \"<string>\",\n    \"name\": \"<string>\",\n    \"type\": null,\n    \"first_name\": \"<string>\",\n    \"last_name\": \"<string>\",\n    \"contact_person\": \"<string>\",\n    \"vat_number\": \"<string>\",\n    \"tax_code\": \"<string>\",\n    \"address_street\": \"<string>\",\n    \"address_postal_code\": \"<string>\",\n    \"address_city\": \"<string>\",\n    \"address_province\": \"<string>\",\n    \"address_extra\": \"<string>\",\n    \"country\": \"<string>\",\n    \"email\": \"<string>\",\n    \"certified_email\": \"<string>\",\n    \"phone\": \"<string>\",\n    \"fax\": \"<string>\",\n    \"notes\": \"<string>\",\n    \"bank_iban\": \"<string>\",\n    \"created_at\": \"<string>\",\n    \"updated_at\": \"<string>\"\n  }\n}"
    },
    {
      "name": "Unauthorized",
      "originalRequest": {
        "method": "PUT",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"data\": {\n    \"name\": \"<string>\",\n    \"id\": \"<integer>\",\n    \"code\": \"<string>\",\n    \"type\": null,\n    \"first_name\": \"<string>\",\n    \"last_name\": \"<string>\",\n    \"contact_person\": \"<string>\",\n    \"vat_number\": \"<string>\",\n    \"tax_code\": \"<string>\",\n    \"address_street\": \"<string>\",\n    \"address_postal_code\": \"<string>\",\n    \"address_city\": \"<string>\",\n    \"address_province\": \"<string>\",\n    \"address_extra\": \"<string>\",\n    \"country\": \"Italia\",\n    \"email\": \"<string>\",\n    \"certified_email\": \"<string>\",\n    \"phone\": \"<string>\",\n    \"fax\": \"<string>\",\n    \"notes\": \"<string>\",\n    \"bank_iban\": \"<string>\",\n    \"created_at\": \"<string>\",\n    \"updated_at\": \"<string>\"\n  }\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/c/:company_id/entities/suppliers/:supplier_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "c",
            ":company_id",
            "entities",
            "suppliers",
            ":supplier_id"
          ],
          "variable": [
            {
              "key": "company_id"
            },
            {
              "key": "supplier_id"
            }
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Not Found",
      "originalRequest": {
        "method": "PUT",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"data\": {\n    \"name\": \"<string>\",\n    \"id\": \"<integer>\",\n    \"code\": \"<string>\",\n    \"type\": null,\n    \"first_name\": \"<string>\",\n    \"last_name\": \"<string>\",\n    \"contact_person\": \"<string>\",\n    \"vat_number\": \"<string>\",\n    \"tax_code\": \"<string>\",\n    \"address_street\": \"<string>\",\n    \"address_postal_code\": \"<string>\",\n    \"address_city\": \"<string>\",\n    \"address_province\": \"<string>\",\n    \"address_extra\": \"<string>\",\n    \"country\": \"Italia\",\n    \"email\": \"<string>\",\n    \"certified_email\": \"<string>\",\n    \"phone\": \"<string>\",\n    \"fax\": \"<string>\",\n    \"notes\": \"<string>\",\n    \"bank_iban\": \"<string>\",\n    \"created_at\": \"<string>\",\n    \"updated_at\": \"<string>\"\n  }\n}",
          "options": {
            "raw": {
              "headerFamily": "json",
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/c/:company_id/entities/suppliers/:supplier_id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "c",
            ":company_id",
            "entities",
            "suppliers",
            ":supplier_id"
          ],
          "variable": [
            {
              "key": "company_id"
            },
            {
              "key": "supplier_id"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}