Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

C Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(C) effectconnect Create or Replace Product Catalog

Use this call to create or replace a product catalog in EffectConnect. This is always a purge and replace action for the entire catalog.

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++

Solaris C/C++

MinGW C/C++

#include <C_CkHttp.h>
#include <C_CkHttpRequest.h>
#include <C_CkDateTime.h>
#include <C_CkStringBuilder.h>
#include <C_CkCrypt2.h>
#include <C_CkHttpResponse.h>
#include <C_CkXml.h>

void ChilkatSample(void)
    {
    BOOL success;
    const char *uri;
    const char *apiVersion;
    HCkHttp http;
    HCkHttpRequest req;
    HCkDateTime dt;
    const char *timestamp;
    HCkStringBuilder sbXml;
    HCkStringBuilder sbStringToSign;
    HCkCrypt2 crypt;
    HCkHttpResponse resp;
    HCkXml xmlResp;
    const char *tagPath;
    const char *RequestType;
    const char *RequestAction;
    const char *RequestVersion;
    const char *ProcessedAt;
    const char *Result;
    const char *ProcessID;

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

    uri = "/products";
    apiVersion = "2.0";

    http = CkHttp_Create();
    req = CkHttpRequest_Create();

    // Use your effectconnect public key here...
    CkHttpRequest_AddHeader(req,"KEY","PUBLIC_KEY");
    CkHttpRequest_AddHeader(req,"VERSION",apiVersion);
    CkHttpRequest_AddHeader(req,"URI",uri);
    CkHttpRequest_AddHeader(req,"RESPONSETYPE","XML");
    CkHttpRequest_AddHeader(req,"RESPONSELANGUAGE","en");

    // Get the current date/time in timestamp format.
    dt = CkDateTime_Create();
    CkDateTime_SetFromCurrentSystemTime(dt);
    timestamp = CkDateTime_getAsTimestamp(dt,TRUE);

    CkHttpRequest_AddHeader(req,"TIME",timestamp);
    printf("timestamp = %s\n",timestamp);

    sbXml = CkStringBuilder_Create();
    success = CkStringBuilder_LoadFile(sbXml,"qa_data/xml/effectconnect/effconCreate.xml","utf-8");
    printf("length = %d\n",CkStringBuilder_getLength(sbXml));

    CkHttpRequest_putHttpVerb(req,"POST");
    CkHttpRequest_putPath(req,uri);
    CkHttpRequest_putContentType(req,"multipart/form-data");
    success = CkHttpRequest_AddStringForUpload(req,"payload","effcon.xml",CkStringBuilder_getAsString(sbXml),"utf-8");
    if (success == FALSE) {
        printf("%s\n",CkHttpRequest_lastErrorText(req));
        CkHttp_Dispose(http);
        CkHttpRequest_Dispose(req);
        CkDateTime_Dispose(dt);
        CkStringBuilder_Dispose(sbXml);
        return;
    }

    // Build a string-to-sign and sign it using our effectconnect private key
    sbStringToSign = CkStringBuilder_Create();
    CkStringBuilder_AppendInt(sbStringToSign,CkStringBuilder_getLength(sbXml));
    CkStringBuilder_Append(sbStringToSign,"POST");
    CkStringBuilder_Append(sbStringToSign,uri);
    CkStringBuilder_Append(sbStringToSign,apiVersion);
    CkStringBuilder_Append(sbStringToSign,timestamp);

    crypt = CkCrypt2_Create();
    CkCrypt2_putMacAlgorithm(crypt,"hmac");
    CkCrypt2_putHashAlgorithm(crypt,"sha512");
    CkCrypt2_putEncodingMode(crypt,"base64");
    // Use your effectconnect private key here:
    CkCrypt2_SetMacKeyString(crypt,"PRIVATE_KEY");
    CkHttpRequest_AddHeader(req,"SIGNATURE",CkCrypt2_macStringENC(crypt,CkStringBuilder_getAsString(sbStringToSign)));

    resp = CkHttp_SynchronousRequest(http,"submit.effectconnect.com",443,TRUE,req);
    if (CkHttp_getLastMethodSuccess(http) == FALSE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkHttp_Dispose(http);
        CkHttpRequest_Dispose(req);
        CkDateTime_Dispose(dt);
        CkStringBuilder_Dispose(sbXml);
        CkStringBuilder_Dispose(sbStringToSign);
        CkCrypt2_Dispose(crypt);
        return;
    }

    printf("response status code = %d\n",CkHttpResponse_getStatusCode(resp));

    // Examine the response.  The response status code can be 200 for both errors and success.
    // The success or error is based on the XML returned in the response body.
    xmlResp = CkXml_Create();
    CkXml_LoadXml(xmlResp,CkHttpResponse_bodyStr(resp));
    CkHttpResponse_Dispose(resp);

    printf("response body:\n");
    printf("%s\n",CkXml_getXml(xmlResp));

    // A sample response:

    // <?xml version="1.0" encoding="utf-8"?>
    // <ApiResponseContainer>
    //     <Request>
    //         <RequestType>Products</RequestType>
    //         <RequestAction>Create</RequestAction>
    //         <RequestVersion>2.0</RequestVersion>
    //         <RequestIdentifier/>
    //         <ProcessedAt>2019-04-18T15:28:55+02:00</ProcessedAt>
    //     </Request>
    //     <Response>
    //         <Result>Success</Result>
    //         <ProductsCreateResponseContainer>
    //             <ProcessID><![CDATA[J048hgS4OkNn0JnH]]></ProcessID>
    //         </ProductsCreateResponseContainer>
    //     </Response>
    // </ApiResponseContainer>

    // Parsing the response...

    RequestType = CkXml_getChildContent(xmlResp,"Request|RequestType");
    RequestAction = CkXml_getChildContent(xmlResp,"Request|RequestAction");
    RequestVersion = CkXml_getChildContent(xmlResp,"Request|RequestVersion");
    ProcessedAt = CkXml_getChildContent(xmlResp,"Request|ProcessedAt");
    Result = CkXml_getChildContent(xmlResp,"Response|Result");
    ProcessID = CkXml_getChildContent(xmlResp,"Response|ProductsCreateResponseContainer|ProcessID");


    CkHttp_Dispose(http);
    CkHttpRequest_Dispose(req);
    CkDateTime_Dispose(dt);
    CkStringBuilder_Dispose(sbXml);
    CkStringBuilder_Dispose(sbStringToSign);
    CkCrypt2_Dispose(crypt);
    CkXml_Dispose(xmlResp);

    }

 

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