Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

DataFlex Web API Examples

Primary Categories

AWS Translate
Activix CRM
Adyen
Amazon MWS
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bluzone
CardConnect
ClickBank
Clickatell
Cloudfare
DocuSign
ETrade
Etsy
Facebook
GeoOp
GetHarvest
Jira
MYOB

Magento
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Okta OAuth/OIDC
OneLogin OIDC
PayPal
Peoplevox
Populi
QuickBooks
SOAP finkok.com
Shippo
Shopify
Stripe
SugarCRM
Trello
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
Xero
eBay
effectconnect

 

 

 

(DataFlex) Walmart - Update bulk inventory

See Update bulk inventory for more information about this call.

Note: This example requires Chilkat v9.5.0.67 or greater.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Boolean iSuccess
    String sUrl
    String sRequestMethod
    Handle hoAuthUtil
    String sWmConsumerId
    String sWmPrivateKey
    String sJsonStr
    Variant vReq
    Handle hoReq
    Handle hoJson
    Handle hoHttp
    Variant vResp
    Handle hoResp
    Handle hoXml
    String sTemp1
    Integer iTemp1
    Boolean bTemp1

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

    // Sends the following POST request:
    // POST https://marketplace.walmartapis.com/v2/feeds?feedType=inventory

    Move "https://marketplace.walmartapis.com/v2/feeds?feedType=inventory" To sUrl

    Move "POST" To sRequestMethod

    // First we need to generate a signature for our request.
    // The signature needs to be re-generated for each new Walmart HTTP request.
    Get Create (RefClass(cComChilkatAuthUtil)) To hoAuthUtil
    If (Not(IsComObjectCreated(hoAuthUtil))) Begin
        Send CreateComObject of hoAuthUtil
    End

    Move "WALMART_CONSUMER_ID" To sWmConsumerId
    Move "WALMART_PRIVATE_KEY" To sWmPrivateKey
    Get ComWalmartSignature Of hoAuthUtil sUrl sWmConsumerId sWmPrivateKey sRequestMethod To sJsonStr
    Get ComLastMethodSuccess Of hoAuthUtil To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoAuthUtil To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Build the HTTP POST request.
    Get Create (RefClass(cComChilkatHttpRequest)) To hoReq
    If (Not(IsComObjectCreated(hoReq))) Begin
        Send CreateComObject of hoReq
    End
    Set ComHttpVerb Of hoReq To "POST"
    Set ComContentType Of hoReq To "multipart/form-data"
    Set ComPath Of hoReq To "/v2/feeds?feedType=inventory"
    Send ComAddHeader To hoReq "Accept" "application/xml"

    // The JSON returned by WalmartSignature contains the values to be used in the following
    // header fields: WM_SEC.AUTH_SIGNATURE, WM_SEC.TIMESTAMP, and WM_QOS.CORRELATION_ID
    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComLoad Of hoJson sJsonStr To iSuccess

    Send ComAddHeader To hoReq "WM_SVC.NAME" "Walmart Marketplace"
    Get ComStringOf Of hoJson "correlation_id" To sTemp1
    Send ComAddHeader To hoReq "WM_QOS.CORRELATION_ID" sTemp1
    Get ComStringOf Of hoJson "timestamp" To sTemp1
    Send ComAddHeader To hoReq "WM_SEC.TIMESTAMP" sTemp1
    Get ComStringOf Of hoJson "signature" To sTemp1
    Send ComAddHeader To hoReq "WM_SEC.AUTH_SIGNATURE" sTemp1
    Send ComAddHeader To hoReq "WM_CONSUMER.ID" sWmConsumerId
    //  Note: Make sure to replace "WALMART_CHANNEL_TYPE" with the actual value for your seller account...
    Send ComAddHeader To hoReq "WM_CONSUMER.CHANNEL.TYPE" "WALMART_CHANNEL_TYPE"

    // The body of the POST will contain XML.  In this example, we'll load the XML
    // from a file.  The XML contains inventory data that looks something like this:

    // <InventoryFeed xmlns="http://walmart.com/">
    //   <InventoryHeader>
    //       <version>1.4</version>
    //   </InventoryHeader>
    //   <inventory>
    //       <sku>1068155</sku>
    //       <quantity>
    //           <unit>EACH</unit>
    //           <amount>10</amount>
    //       </quantity>
    //       <fulfillmentLagTime>1</fulfillmentLagTime>
    //   </inventory>
    //   <inventory>
    //       <sku>10210321</sku>
    //       <quantity>
    //           <unit>EACH</unit>
    //           <amount>20</amount>
    //       </quantity>
    //       <fulfillmentLagTime>3</fulfillmentLagTime>
    //   </inventory>
    // </InventoryFeed>

    Get ComAddFileForUpload2 Of hoReq "inventory" "qa_data/walmart/inventory.xml" "application/xml" To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoReq To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End
    Get pvComObject of hoReq to vReq
    Get ComSynchronousRequest Of hoHttp "marketplace.walmartapis.com" 443 True vReq To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatXml)) To hoXml
    If (Not(IsComObjectCreated(hoXml))) Begin
        Send CreateComObject of hoXml
    End
    Get ComBodyStr Of hoResp To sTemp1
    Get ComLoadXml Of hoXml sTemp1 To iSuccess

    // A successful response should have a 200 response status
    Get ComStatusCode Of hoResp To iTemp1
    If (iTemp1 <> 200) Begin
        Get ComGetXml Of hoXml To sTemp1
        Showln sTemp1
        Get ComStatusCode Of hoResp To iTemp1
        Showln "Response Status Code: " iTemp1
        Showln "Failed."
        Send Destroy of hoResp
        Procedure_Return
    End

    Send Destroy of hoResp

    // Show the XML response..
    Get ComGetXml Of hoXml To sTemp1
    Showln sTemp1
    Showln "--"
    Showln "Success!"


End_Procedure

 

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