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

PowerBuilder 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
Cloud Signature CSC
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
uncategorized

 

 

 

(PowerBuilder) effectconnect Product Update

Use this call to update a product (f.e. stock or price) in EffectConnect.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

integer li_rc
integer li_Success
string ls_Uri
string ls_ApiVersion
oleobject loo_Http
oleobject loo_Req
oleobject loo_Dt
string ls_Timestamp
oleobject loo_SbXml
oleobject loo_SbStringToSign
oleobject loo_Crypt
oleobject loo_Resp
oleobject loo_XmlResp
string ls_TagPath
string ls_RequestType
string ls_RequestAction
string ls_RequestVersion
string ls_ProcessedAt
string ls_Result
string ls_ProcessID

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

ls_Uri = "/products"
ls_ApiVersion = "2.0"

loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if
loo_Req = create oleobject
// Use "Chilkat_9_5_0.HttpRequest" for versions of Chilkat < 10.0.0
li_rc = loo_Req.ConnectToNewObject("Chilkat.HttpRequest")

// Use your effectconnect public key here...
loo_Req.AddHeader("KEY","PUBLIC_KEY")
loo_Req.AddHeader("VERSION",ls_ApiVersion)
loo_Req.AddHeader("URI",ls_Uri)
loo_Req.AddHeader("RESPONSETYPE","XML")
loo_Req.AddHeader("RESPONSELANGUAGE","en")

// Get the current date/time in timestamp format.
loo_Dt = create oleobject
// Use "Chilkat_9_5_0.CkDateTime" for versions of Chilkat < 10.0.0
li_rc = loo_Dt.ConnectToNewObject("Chilkat.CkDateTime")

loo_Dt.SetFromCurrentSystemTime()
ls_Timestamp = loo_Dt.GetAsTimestamp(1)

loo_Req.AddHeader("TIME",ls_Timestamp)
Write-Debug "timestamp = " + ls_Timestamp

loo_SbXml = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbXml.ConnectToNewObject("Chilkat.StringBuilder")

li_Success = loo_SbXml.LoadFile("qa_data/xml/effectconnect/effconUpdate.xml","utf-8")
Write-Debug "length = " + string(loo_SbXml.Length)

loo_Req.HttpVerb = "PUT"
loo_Req.Path = ls_Uri
loo_Req.ContentType = "multipart/form-data"
li_Success = loo_Req.AddStringForUpload("payload","effconUpdate.xml",loo_SbXml.GetAsString(),"utf-8")
if li_Success = 0 then
    Write-Debug loo_Req.LastErrorText
    destroy loo_Http
    destroy loo_Req
    destroy loo_Dt
    destroy loo_SbXml
    return
end if

// Build a string-to-sign and sign it using our effectconnect private key
loo_SbStringToSign = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbStringToSign.ConnectToNewObject("Chilkat.StringBuilder")

loo_SbStringToSign.AppendInt(loo_SbXml.Length)
loo_SbStringToSign.Append("PUT")
loo_SbStringToSign.Append(ls_Uri)
loo_SbStringToSign.Append(ls_ApiVersion)
loo_SbStringToSign.Append(ls_Timestamp)

loo_Crypt = create oleobject
// Use "Chilkat_9_5_0.Crypt2" for versions of Chilkat < 10.0.0
li_rc = loo_Crypt.ConnectToNewObject("Chilkat.Crypt2")

loo_Crypt.MacAlgorithm = "hmac"
loo_Crypt.HashAlgorithm = "sha512"
loo_Crypt.EncodingMode = "base64"
// Use your effectconnect private key here:
loo_Crypt.SetMacKeyString("PRIVATE_KEY")
loo_Req.AddHeader("SIGNATURE",loo_Crypt.MacStringENC(loo_SbStringToSign.GetAsString()))

loo_Resp = loo_Http.SynchronousRequest("submit.effectconnect.com",443,1,loo_Req)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Req
    destroy loo_Dt
    destroy loo_SbXml
    destroy loo_SbStringToSign
    destroy loo_Crypt
    return
end if

Write-Debug "response status code = " + string(loo_Resp.StatusCode)

// 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.
loo_XmlResp = create oleobject
// Use "Chilkat_9_5_0.Xml" for versions of Chilkat < 10.0.0
li_rc = loo_XmlResp.ConnectToNewObject("Chilkat.Xml")

loo_XmlResp.LoadXml(loo_Resp.BodyStr)
destroy loo_Resp

Write-Debug "response body:"
Write-Debug loo_XmlResp.GetXml()

// A sample response:

// <?xml version="1.0" encoding="utf-8"?>
// <ApiResponseContainer>
//     <Request>
//         <RequestType>Products</RequestType>
//         <RequestAction>Update</RequestAction>
//         <RequestVersion>2.0</RequestVersion>
//         <RequestIdentifier/>
//         <ProcessedAt>2019-04-18T15:37:32+02:00</ProcessedAt>
//     </Request>
//     <Response>
//         <Result>Success</Result>
//         <ProductsUpdateResponseContainer>
//             <ProcessID><![CDATA[f81ngzD2S7gooFk3]]></ProcessID>
//         </ProductsUpdateResponseContainer>
//     </Response>
// </ApiResponseContainer>
// 

ls_RequestType = loo_XmlResp.GetChildContent("Request|RequestType")
ls_RequestAction = loo_XmlResp.GetChildContent("Request|RequestAction")
ls_RequestVersion = loo_XmlResp.GetChildContent("Request|RequestVersion")
ls_ProcessedAt = loo_XmlResp.GetChildContent("Request|ProcessedAt")
ls_Result = loo_XmlResp.GetChildContent("Response|Result")
ls_ProcessID = loo_XmlResp.GetChildContent("Response|ProductsUpdateResponseContainer|ProcessID")


destroy loo_Http
destroy loo_Req
destroy loo_Dt
destroy loo_SbXml
destroy loo_SbStringToSign
destroy loo_Crypt
destroy loo_XmlResp

 

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