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

DataFlex 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

 

 

 

(DataFlex) Shopify Create New Product

Create a new product

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoRest
    Boolean iSuccess
Req    Handle hoJsonReq
    Variant vSbReq
    Handle hoSbReq
    Variant vSbJson
    Handle hoSbJson
    Handle hoJson
    Integer iProductId
    String sProductTitle
    String sProductBody_html
    String sProductVendor
    String sProductProduct_type
    String sProductCreated_at
    String sProductHandle
    String sProductUpdated_at
    String sProductPublished_at
    Boolean iProductTemplate_suffix
    String sProductPublished_scope
    String sProductTags
    Integer iProductImageId
    Integer iProductImageProduct_id
    Integer iProductImagePosition
    String sProductImageCreated_at
    String sProductImageUpdated_at
    Integer iProductImageWidth
    Integer iProductImageHeight
    String sProductImageSrc
    Integer i
    Integer iCount_i
    Integer iId
    Integer iProduct_id
    String sTitle
    String sPrice
    String sSku
    Integer iPosition
    Integer iGrams
    String sInventory_policy
    Boolean iCompare_at_price
    String sFulfillment_service
    Boolean iInventory_management
    String sOption1
    Boolean iOption2
    Boolean iOption3
    String sCreated_at
    String sUpdated_at
    Boolean iTaxable
    Boolean iBarcode
    Boolean iImage_id
    Integer iInventory_quantity
    Integer iWeight
    String sWeight_unit
    Integer iOld_inventory_quantity
    Boolean iRequires_shipping
    String sName
    Integer j
    Integer iCount_j
    String sStrVal
    Integer iWidth
    Integer iHeight
    String sSrc
    String sTemp1
    Integer iTemp1

    Get Create (RefClass(cComChilkatRest)) To hoRest
    If (Not(IsComObjectCreated(hoRest))) Begin
        Send CreateComObject of hoRest
    End

    Get ComSetAuthBasic Of hoRest "SHOPIFY_PRIVATE_API_KEY" "SHOPIFY_PRIVATE_API_SECRET_KEY" To iSuccess

    Get ComConnect Of hoRest "chilkat.myshopify.com" 443 True True To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // The following code creates the JSON request body.
    // The JSON created by this code is shown below.
    Get Create (RefClass(cComChilkatJsonObject)) To hoJsonReq
    If (Not(IsComObjectCreated(hoJsonReq))) Begin
        Send CreateComObject of hoJsonReq
    End
    Get ComUpdateString Of hoJsonReq "product.title" "Burton Custom Freestyle 151" To iSuccess
    Get ComUpdateString Of hoJsonReq "product.body_html" "<strong>Good snowboard!</strong>" To iSuccess
    Get ComUpdateString Of hoJsonReq "product.vendor" "Burton" To iSuccess
    Get ComUpdateString Of hoJsonReq "product.product_type" "Snowboard" To iSuccess
    Get ComUpdateString Of hoJsonReq "product.images[0].attachment" "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" To iSuccess

    // The JSON request body created by the above code:

    // {
    //   "product": {
    //     "title": "Burton Custom Freestyle 151",
    //     "body_html": "<strong>Good snowboard!<\/strong>",
    //     "vendor": "Burton",
    //     "product_type": "Snowboard",
    //     "images": [
    //       {
    //         "attachment": "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
    //       }
    //     ]
    //   }
    // }

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbReq
    If (Not(IsComObjectCreated(hoSbReq))) Begin
        Send CreateComObject of hoSbReq
    End
    Get pvComObject of hoSbReq to vSbReq
    Get ComEmitSb Of hoJsonReq vSbReq To iSuccess

    Get ComAddHeader Of hoRest "Content-Type" "application/json" To iSuccess

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbJson
    If (Not(IsComObjectCreated(hoSbJson))) Begin
        Send CreateComObject of hoSbJson
    End
    Get pvComObject of hoSbReq to vSbReq
    Get pvComObject of hoSbJson to vSbJson
    Get ComFullRequestSb Of hoRest "POST" "/admin/products.json" vSbReq vSbJson To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComResponseStatusCode Of hoRest To iTemp1
    If (iTemp1 <> 201) Begin
        Get ComResponseStatusCode Of hoRest To iTemp1
        Showln "Received error response code: " iTemp1
        Showln "Response body:"
        Get ComGetAsString Of hoSbJson To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get pvComObject of hoSbJson to vSbJson
    Get ComLoadSb Of hoJson vSbJson To iSuccess

    // The following code parses the JSON response.
    // A sample JSON response is shown below the sample code.

    Get ComIntOf Of hoJson "product.id" To iProductId
    Get ComStringOf Of hoJson "product.title" To sProductTitle
    Get ComStringOf Of hoJson "product.body_html" To sProductBody_html
    Get ComStringOf Of hoJson "product.vendor" To sProductVendor
    Get ComStringOf Of hoJson "product.product_type" To sProductProduct_type
    Get ComStringOf Of hoJson "product.created_at" To sProductCreated_at
    Get ComStringOf Of hoJson "product.handle" To sProductHandle
    Get ComStringOf Of hoJson "product.updated_at" To sProductUpdated_at
    Get ComStringOf Of hoJson "product.published_at" To sProductPublished_at
    Get ComIsNullOf Of hoJson "product.template_suffix" To iProductTemplate_suffix
    Get ComStringOf Of hoJson "product.published_scope" To sProductPublished_scope
    Get ComStringOf Of hoJson "product.tags" To sProductTags
    Get ComIntOf Of hoJson "product.image.id" To iProductImageId
    Get ComIntOf Of hoJson "product.image.product_id" To iProductImageProduct_id
    Get ComIntOf Of hoJson "product.image.position" To iProductImagePosition
    Get ComStringOf Of hoJson "product.image.created_at" To sProductImageCreated_at
    Get ComStringOf Of hoJson "product.image.updated_at" To sProductImageUpdated_at
    Get ComIntOf Of hoJson "product.image.width" To iProductImageWidth
    Get ComIntOf Of hoJson "product.image.height" To iProductImageHeight
    Get ComStringOf Of hoJson "product.image.src" To sProductImageSrc
    Move 0 To i
    Get ComSizeOfArray Of hoJson "product.variants" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComIntOf Of hoJson "product.variants[i].id" To iId
        Get ComIntOf Of hoJson "product.variants[i].product_id" To iProduct_id
        Get ComStringOf Of hoJson "product.variants[i].title" To sTitle
        Get ComStringOf Of hoJson "product.variants[i].price" To sPrice
        Get ComStringOf Of hoJson "product.variants[i].sku" To sSku
        Get ComIntOf Of hoJson "product.variants[i].position" To iPosition
        Get ComIntOf Of hoJson "product.variants[i].grams" To iGrams
        Get ComStringOf Of hoJson "product.variants[i].inventory_policy" To sInventory_policy
        Get ComIsNullOf Of hoJson "product.variants[i].compare_at_price" To iCompare_at_price
        Get ComStringOf Of hoJson "product.variants[i].fulfillment_service" To sFulfillment_service
        Get ComIsNullOf Of hoJson "product.variants[i].inventory_management" To iInventory_management
        Get ComStringOf Of hoJson "product.variants[i].option1" To sOption1
        Get ComIsNullOf Of hoJson "product.variants[i].option2" To iOption2
        Get ComIsNullOf Of hoJson "product.variants[i].option3" To iOption3
        Get ComStringOf Of hoJson "product.variants[i].created_at" To sCreated_at
        Get ComStringOf Of hoJson "product.variants[i].updated_at" To sUpdated_at
        Get ComBoolOf Of hoJson "product.variants[i].taxable" To iTaxable
        Get ComIsNullOf Of hoJson "product.variants[i].barcode" To iBarcode
        Get ComIsNullOf Of hoJson "product.variants[i].image_id" To iImage_id
        Get ComIntOf Of hoJson "product.variants[i].inventory_quantity" To iInventory_quantity
        Get ComIntOf Of hoJson "product.variants[i].weight" To iWeight
        Get ComStringOf Of hoJson "product.variants[i].weight_unit" To sWeight_unit
        Get ComIntOf Of hoJson "product.variants[i].old_inventory_quantity" To iOld_inventory_quantity
        Get ComBoolOf Of hoJson "product.variants[i].requires_shipping" To iRequires_shipping
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJson "product.options" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComIntOf Of hoJson "product.options[i].id" To iId
        Get ComIntOf Of hoJson "product.options[i].product_id" To iProduct_id
        Get ComStringOf Of hoJson "product.options[i].name" To sName
        Get ComIntOf Of hoJson "product.options[i].position" To iPosition
        Move 0 To j
        Get ComSizeOfArray Of hoJson "product.options[i].values" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComStringOf Of hoJson "product.options[i].values[j]" To sStrVal
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJson "product.images" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComIntOf Of hoJson "product.images[i].id" To iId
        Get ComIntOf Of hoJson "product.images[i].product_id" To iProduct_id
        Get ComIntOf Of hoJson "product.images[i].position" To iPosition
        Get ComStringOf Of hoJson "product.images[i].created_at" To sCreated_at
        Get ComStringOf Of hoJson "product.images[i].updated_at" To sUpdated_at
        Get ComIntOf Of hoJson "product.images[i].width" To iWidth
        Get ComIntOf Of hoJson "product.images[i].height" To iHeight
        Get ComStringOf Of hoJson "product.images[i].src" To sSrc
        Move 0 To j
        Get ComSizeOfArray Of hoJson "product.images[i].variant_ids" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Move (j + 1) To j
        Loop

        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJson "image.product.variant_ids" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Move (i + 1) To i
    Loop

    // A sample JSON response body that is parsed by the above code:

    // {
    //   "product": {
    //     "id": 1071559747,
    //     "title": "Burton Custom Freestyle 151",
    //     "body_html": "<strong>Good snowboard!<\/strong>",
    //     "vendor": "Burton",
    //     "product_type": "Snowboard",
    //     "created_at": "2017-09-22T14:48:43-04:00",
    //     "handle": "burton-custom-freestyle-151",
    //     "updated_at": "2017-09-22T14:48:44-04:00",
    //     "published_at": "2017-09-22T14:48:43-04:00",
    //     "template_suffix": null,
    //     "published_scope": "global",
    //     "tags": "",
    //     "variants": [
    //       {
    //         "id": 1070325218,
    //         "product_id": 1071559747,
    //         "title": "Default Title",
    //         "price": "0.00",
    //         "sku": "",
    //         "position": 1,
    //         "grams": 0,
    //         "inventory_policy": "deny",
    //         "compare_at_price": null,
    //         "fulfillment_service": "manual",
    //         "inventory_management": null,
    //         "option1": "Default Title",
    //         "option2": null,
    //         "option3": null,
    //         "created_at": "2017-09-22T14:48:44-04:00",
    //         "updated_at": "2017-09-22T14:48:44-04:00",
    //         "taxable": true,
    //         "barcode": null,
    //         "image_id": null,
    //         "inventory_quantity": 1,
    //         "weight": 0.0,
    //         "weight_unit": "lb",
    //         "old_inventory_quantity": 1,
    //         "requires_shipping": true
    //       }
    //     ],
    //     "options": [
    //       {
    //         "id": 1022828903,
    //         "product_id": 1071559747,
    //         "name": "Title",
    //         "position": 1,
    //         "values": [
    //           "Default Title"
    //         ]
    //       }
    //     ],
    //     "images": [
    //       {
    //         "id": 1001473945,
    //         "product_id": 1071559747,
    //         "position": 1,
    //         "created_at": "2017-09-22T14:48:43-04:00",
    //         "updated_at": "2017-09-22T14:48:43-04:00",
    //         "width": 1,
    //         "height": 1,
    //         "src": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/products\/df3e567d6f16d040326c7a0ea29a4f41.gif?v=1506106123",
    //         "variant_ids": [
    //         ]
    //       }
    //     ],
    //     "image": {
    //       "id": 1001473945,
    //       "product_id": 1071559747,
    //       "position": 1,
    //       "created_at": "2017-09-22T14:48:43-04:00",
    //       "updated_at": "2017-09-22T14:48:43-04:00",
    //       "width": 1,
    //       "height": 1,
    //       "src": "https:\/\/cdn.shopify.com\/s\/files\/1\/0006\/9093\/3842\/products\/df3e567d6f16d040326c7a0ea29a4f41.gif?v=1506106123",
    //       "variant_ids": [
    //       ]
    //     }
    //   }
    // }

    Showln "Example Completed."


End_Procedure

 

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