Chilkat Examples

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

DataFlex Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Bitfinex v2 REST
Bluzone
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun

MedTunnel
MercadoLibre
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Okta OAuth/OIDC
OneLogin OIDC
OneNote
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter
UniPin
VoiceBase
Vonage
Walmart
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yousign
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(DataFlex) Lightspeed - Create a Product

Create a new product based on the given parameters.

For more information, see https://developers.lightspeedhq.com/ecom/endpoints/product/#post-create-a-product

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vJson
    Handle hoJson
    Variant vResp
    Handle hoResp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    Integer iProductId
    String sProductCreatedAt
    String sProductUpdatedAt
    Boolean iProductIsVisible
    String sProductVisibility
    Boolean iProductHasMatrix
    String sProductData01
    String sProductData02
    String sProductData03
    String sProductUrl
    String sProductTitle
    String sProductFulltitle
    String sProductDescription
    String sProductContent
    Boolean iProductSet
    Integer iProductBrandResourceId
    String sProductBrandResourceUrl
    String sProductBrandResourceLink
    Boolean iProductCategoriesResourceId
    String sProductCategoriesResourceUrl
    String sProductCategoriesResourceLink
    Integer iProductDeliverydateResourceId
    String sProductDeliverydateResourceUrl
    String sProductDeliverydateResourceLink
    Boolean iProductImage
    Boolean iProductImages
    Boolean iProductRelationsResourceId
    String sProductRelationsResourceUrl
    String sProductRelationsResourceLink
    Boolean iProductMetafieldsResourceId
    String sProductMetafieldsResourceUrl
    String sProductMetafieldsResourceLink
    Boolean iProductReviewsResourceId
    String sProductReviewsResourceUrl
    String sProductReviewsResourceLink
    Boolean iProductType
    Boolean iProductAttributesResourceId
    String sProductAttributesResourceUrl
    String sProductAttributesResourceLink
    Integer iProductSupplierResourceId
    String sProductSupplierResourceUrl
    String sProductSupplierResourceLink
    Boolean iProductTagsResourceId
    String sProductTagsResourceUrl
    String sProductTagsResourceLink
    Boolean iProductVariantsResourceId
    String sProductVariantsResourceUrl
    String sProductVariantsResourceLink
    Boolean iProductMovementsResourceId
    String sProductMovementsResourceUrl
    String sProductMovementsResourceLink
    String sTemp1
    Boolean bTemp1

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

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    // Implements the following CURL command:

    // curl   -u API_KEY:API_SECRET \
    //     -H "Content-Type: application/json" \
    //     -X POST \
    //     -d '{
    //   "product": {
    //     "visibility": "visible",
    //     "data01": "",
    //     "data02": "",
    //     "data03": "",
    //     "title": "Lookin Sharp T-Shirt",
    //     "fulltitle": "Lookin Sharp T-Shirt",
    //     "description": "Description of the Lookin Sharp T-Shirt",
    //     "content": "Long Description of the Lookin Sharp T-Shirt",
    //     "deliverydate": 6488,
    //     "supplier": 78794,
    //     "brand": 1171202
    //   }
    // }' \
    // "https://api.webshopapp.com/en/products.json"

    // Use the following online tool to generate HTTP code from a CURL command
    // Convert a cURL Command to HTTP Source Code

    Set ComLogin Of hoHttp To "API_KEY"
    Set ComPassword Of hoHttp To "API_SECRET"

    // Use this online tool to generate code from sample JSON:
    // Generate Code to Create JSON

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

    // {
    //   "product": {
    //     "visibility": "visible",
    //     "data01": "",
    //     "data02": "",
    //     "data03": "",
    //     "title": "Lookin Sharp T-Shirt",
    //     "fulltitle": "Lookin Sharp T-Shirt",
    //     "description": "Description of the Lookin Sharp T-Shirt",
    //     "content": "Long Description of the Lookin Sharp T-Shirt",
    //     "deliverydate": 6488,
    //     "supplier": 78794,
    //     "brand": 1171202
    //   }
    // }

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "product.visibility" "visible" To iSuccess
    Get ComUpdateString Of hoJson "product.data01" "" To iSuccess
    Get ComUpdateString Of hoJson "product.data02" "" To iSuccess
    Get ComUpdateString Of hoJson "product.data03" "" To iSuccess
    Get ComUpdateString Of hoJson "product.title" "Lookin Sharp T-Shirt" To iSuccess
    Get ComUpdateString Of hoJson "product.fulltitle" "Lookin Sharp T-Shirt" To iSuccess
    Get ComUpdateString Of hoJson "product.description" "Description of the Lookin Sharp T-Shirt" To iSuccess
    Get ComUpdateString Of hoJson "product.content" "Long Description of the Lookin Sharp T-Shirt" To iSuccess
    Get ComUpdateInt Of hoJson "product.deliverydate" 6488 To iSuccess
    Get ComUpdateInt Of hoJson "product.supplier" 78794 To iSuccess
    Get ComUpdateInt Of hoJson "product.brand" 1171202 To iSuccess

    Send ComSetRequestHeader To hoHttp "Content-Type" "application/json"

    // Use the correct cluster for your shop.  Here are the choices:
    // eu1 https://api.webshopapp.com/en/
    // us1 https://api.shoplightspeed.com/en/
    Get pvComObject of hoJson to vJson
    Get ComPostJson3 Of hoHttp "https://api.webshopapp.com/en/products.json" "application/json" vJson 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 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess
    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComStatusCode Of hoResp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComHeader Of hoResp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Send Destroy of hoResp
        Procedure_Return
    End

    Send Destroy of hoResp

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "product": {
    //     "id": 20974460,
    //     "createdAt": "2019-05-28T20:14:26+00:00",
    //     "updatedAt": "2019-05-28T20:14:26+00:00",
    //     "isVisible": true,
    //     "visibility": "visible",
    //     "hasMatrix": false,
    //     "data01": "",
    //     "data02": "",
    //     "data03": "",
    //     "url": "lookin-sharp-t-shirt",
    //     "title": "Lookin' Sharp T-Shirt",
    //     "fulltitle": "Lookin' Sharp T-Shirt",
    //     "description": "Description of the Lookin' Sharp T-Shirt",
    //     "content": "<p>Long Description of the Lookin' Sharp T-Shirt</p>",
    //     "set": false,
    //     "brand": {
    //       "resource": {
    //         "id": 1171202,
    //         "url": "brands/1171202",
    //         "link": "https://api.shoplightspeed.com/us/brands/1171202.json"
    //       }
    //     },
    //     "categories": {
    //       "resource": {
    //         "id": false,
    //         "url": "categories/products?product=20974460",
    //         "link": "https://api.shoplightspeed.com/us/categories/products.json?product=20974460"
    //       }
    //     },
    //     "deliverydate": {
    //       "resource": {
    //         "id": 6488,
    //         "url": "deliverydates/6488",
    //         "link": "https://api.shoplightspeed.com/us/deliverydates/6488.json"
    //       }
    //     },
    //     "image": false,
    //     "images": false,
    //     "relations": {
    //       "resource": {
    //         "id": false,
    //         "url": "products/20974460/relations",
    //         "link": "https://api.shoplightspeed.com/us/products/20974460/relations.json"
    //       }
    //     },
    //     "metafields": {
    //       "resource": {
    //         "id": false,
    //         "url": "products/20974460/metafields",
    //         "link": "https://api.shoplightspeed.com/us/products/20974460/metafields.json"
    //       }
    //     },
    //     "reviews": {
    //       "resource": {
    //         "id": false,
    //         "url": "reviews?product=20974460",
    //         "link": "https://api.shoplightspeed.com/us/reviews.json?product=20974460"
    //       }
    //     },
    //     "type": false,
    //     "attributes": {
    //       "resource": {
    //         "id": false,
    //         "url": "products/20974460/attributes",
    //         "link": "https://api.shoplightspeed.com/us/products/20974460/attributes.json"
    //       }
    //     },
    //     "supplier": {
    //       "resource": {
    //         "id": 78794,
    //         "url": "suppliers/78794",
    //         "link": "https://api.shoplightspeed.com/us/suppliers/78794.json"
    //       }
    //     },
    //     "tags": {
    //       "resource": {
    //         "id": false,
    //         "url": "tags/products?product=20974460",
    //         "link": "https://api.shoplightspeed.com/us/tags/products.json?product=20974460"
    //       }
    //     },
    //     "variants": {
    //       "resource": {
    //         "id": false,
    //         "url": "variants?product=20974460",
    //         "link": "https://api.shoplightspeed.com/us/variants.json?product=20974460"
    //       }
    //     },
    //     "movements": {
    //       "resource": {
    //         "id": false,
    //         "url": "variants/movements?product=20974460",
    //         "link": "https://api.shoplightspeed.com/us/variants/movements.json?product=20974460"
    //       }
    //     }
    //   }
    // }

    // Sample code for parsing the JSON response...
    // Use the following online tool to generate parsing code from sample JSON:
    // Generate Parsing Code from JSON

    Get ComIntOf Of hoJResp "product.id" To iProductId
    Get ComStringOf Of hoJResp "product.createdAt" To sProductCreatedAt
    Get ComStringOf Of hoJResp "product.updatedAt" To sProductUpdatedAt
    Get ComBoolOf Of hoJResp "product.isVisible" To iProductIsVisible
    Get ComStringOf Of hoJResp "product.visibility" To sProductVisibility
    Get ComBoolOf Of hoJResp "product.hasMatrix" To iProductHasMatrix
    Get ComStringOf Of hoJResp "product.data01" To sProductData01
    Get ComStringOf Of hoJResp "product.data02" To sProductData02
    Get ComStringOf Of hoJResp "product.data03" To sProductData03
    Get ComStringOf Of hoJResp "product.url" To sProductUrl
    Get ComStringOf Of hoJResp "product.title" To sProductTitle
    Get ComStringOf Of hoJResp "product.fulltitle" To sProductFulltitle
    Get ComStringOf Of hoJResp "product.description" To sProductDescription
    Get ComStringOf Of hoJResp "product.content" To sProductContent
    Get ComBoolOf Of hoJResp "product.set" To iProductSet
    Get ComIntOf Of hoJResp "product.brand.resource.id" To iProductBrandResourceId
    Get ComStringOf Of hoJResp "product.brand.resource.url" To sProductBrandResourceUrl
    Get ComStringOf Of hoJResp "product.brand.resource.link" To sProductBrandResourceLink
    Get ComBoolOf Of hoJResp "product.categories.resource.id" To iProductCategoriesResourceId
    Get ComStringOf Of hoJResp "product.categories.resource.url" To sProductCategoriesResourceUrl
    Get ComStringOf Of hoJResp "product.categories.resource.link" To sProductCategoriesResourceLink
    Get ComIntOf Of hoJResp "product.deliverydate.resource.id" To iProductDeliverydateResourceId
    Get ComStringOf Of hoJResp "product.deliverydate.resource.url" To sProductDeliverydateResourceUrl
    Get ComStringOf Of hoJResp "product.deliverydate.resource.link" To sProductDeliverydateResourceLink
    Get ComBoolOf Of hoJResp "product.image" To iProductImage
    Get ComBoolOf Of hoJResp "product.images" To iProductImages
    Get ComBoolOf Of hoJResp "product.relations.resource.id" To iProductRelationsResourceId
    Get ComStringOf Of hoJResp "product.relations.resource.url" To sProductRelationsResourceUrl
    Get ComStringOf Of hoJResp "product.relations.resource.link" To sProductRelationsResourceLink
    Get ComBoolOf Of hoJResp "product.metafields.resource.id" To iProductMetafieldsResourceId
    Get ComStringOf Of hoJResp "product.metafields.resource.url" To sProductMetafieldsResourceUrl
    Get ComStringOf Of hoJResp "product.metafields.resource.link" To sProductMetafieldsResourceLink
    Get ComBoolOf Of hoJResp "product.reviews.resource.id" To iProductReviewsResourceId
    Get ComStringOf Of hoJResp "product.reviews.resource.url" To sProductReviewsResourceUrl
    Get ComStringOf Of hoJResp "product.reviews.resource.link" To sProductReviewsResourceLink
    Get ComBoolOf Of hoJResp "product.type" To iProductType
    Get ComBoolOf Of hoJResp "product.attributes.resource.id" To iProductAttributesResourceId
    Get ComStringOf Of hoJResp "product.attributes.resource.url" To sProductAttributesResourceUrl
    Get ComStringOf Of hoJResp "product.attributes.resource.link" To sProductAttributesResourceLink
    Get ComIntOf Of hoJResp "product.supplier.resource.id" To iProductSupplierResourceId
    Get ComStringOf Of hoJResp "product.supplier.resource.url" To sProductSupplierResourceUrl
    Get ComStringOf Of hoJResp "product.supplier.resource.link" To sProductSupplierResourceLink
    Get ComBoolOf Of hoJResp "product.tags.resource.id" To iProductTagsResourceId
    Get ComStringOf Of hoJResp "product.tags.resource.url" To sProductTagsResourceUrl
    Get ComStringOf Of hoJResp "product.tags.resource.link" To sProductTagsResourceLink
    Get ComBoolOf Of hoJResp "product.variants.resource.id" To iProductVariantsResourceId
    Get ComStringOf Of hoJResp "product.variants.resource.url" To sProductVariantsResourceUrl
    Get ComStringOf Of hoJResp "product.variants.resource.link" To sProductVariantsResourceLink
    Get ComBoolOf Of hoJResp "product.movements.resource.id" To iProductMovementsResourceId
    Get ComStringOf Of hoJResp "product.movements.resource.url" To sProductMovementsResourceUrl
    Get ComStringOf Of hoJResp "product.movements.resource.link" To sProductMovementsResourceLink


End_Procedure

 

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