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++ Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(C++) MyInvois Malaysia Submit Document

See more Malaysia MyInvois Examples

Demonstrates how to submit a document to MyInvois.

For more information, see https://sdk.myinvois.hasil.gov.my/einvoicingapi/02-submit-documents/

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 <CkHttp.h>
#include <CkStringBuilder.h>
#include <CkJsonObject.h>
#include <CkHttpResponse.h>

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

    CkHttp http;
    bool success;

    // The following JSON is sent in the request body.

    // {
    //   "documents": [
    //     {
    //       "format": "XML",
    //       "documentHash": "<SHA256_hash_of_document>",
    //       "codeNumber": "INV12345",
    //       "document": "<Document_encoded_in_Base64>"
    //     }
    //   ]
    // }

    // Load the document to be sent.
    CkStringBuilder sbXmlDoc;
    success = sbXmlDoc.LoadFile("c:/invoices/invoice1.xml","utf-8");

    // The MyInvois online documentation neglects to tell us the encoding of the documentHash.
    // Should it be base64?  Or hex?  We can only guess.  MyInvois provides no samples,
    // and omits these crucial details which are needed for actual implementation.
    // 
    // *** Note: It was confirmed that "hex" is the encoding that is needed.
    const char *sha256 = sbXmlDoc.getHash("sha256","hex","utf-8");

    CkStringBuilder sbEncoded;
    sbEncoded.AppendSb(sbXmlDoc);
    sbEncoded.Encode("base64","utf-8");

    CkJsonObject json;
    json.UpdateString("documents[0].format","XML");
    json.UpdateString("documents[0].documentHash",sha256);
    json.UpdateString("documents[0].codeNumber","INV12345");
    json.UpdateSb("documents[0].document",sbEncoded);

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

    CkHttpResponse *resp = http.PostJson3("https://preprod-api.myinvois.hasil.gov.my/api/v1.0/documentsubmissions","application/json",json);
    if (http.get_LastMethodSuccess() == false) {
        std::cout << http.lastErrorText() << "\r\n";
        return;
    }

    std::cout << "response status code = " << resp->get_StatusCode() << "\r\n";
    std::cout << resp->bodyStr() << "\r\n";

    delete resp;
    }

 

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