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

Tcl 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

 

 

 

(Tcl) 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 Tcl Extension Downloads

Chilkat Tcl Extension Downloads

load ./chilkat.dll

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

set http [new_CkHttp]

# 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

CkHttp_put_Login $http "API_KEY"
CkHttp_put_Password $http "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
#   }
# }

set json [new_CkJsonObject]

CkJsonObject_UpdateString $json "product.visibility" "visible"
CkJsonObject_UpdateString $json "product.data01" ""
CkJsonObject_UpdateString $json "product.data02" ""
CkJsonObject_UpdateString $json "product.data03" ""
CkJsonObject_UpdateString $json "product.title" "Lookin Sharp T-Shirt"
CkJsonObject_UpdateString $json "product.fulltitle" "Lookin Sharp T-Shirt"
CkJsonObject_UpdateString $json "product.description" "Description of the Lookin Sharp T-Shirt"
CkJsonObject_UpdateString $json "product.content" "Long Description of the Lookin Sharp T-Shirt"
CkJsonObject_UpdateInt $json "product.deliverydate" 6488
CkJsonObject_UpdateInt $json "product.supplier" 78794
CkJsonObject_UpdateInt $json "product.brand" 1171202

CkHttp_SetRequestHeader $http "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/
# resp is a CkHttpResponse
set resp [CkHttp_PostJson3 $http "https://api.webshopapp.com/en/products.json" "application/json" $json]
if {[CkHttp_get_LastMethodSuccess $http] == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkHttp $http
    delete_CkJsonObject $json
    exit
}

set sbResponseBody [new_CkStringBuilder]

CkHttpResponse_GetBodySb $resp $sbResponseBody
set jResp [new_CkJsonObject]

CkJsonObject_LoadSb $jResp $sbResponseBody
CkJsonObject_put_EmitCompact $jResp 0

puts "Response Body:"
puts [CkJsonObject_emit $jResp]

set respStatusCode [CkHttpResponse_get_StatusCode $resp]
puts "Response Status Code = $respStatusCode"
if {$respStatusCode >= 400} then {
    puts "Response Header:"
    puts [CkHttpResponse_header $resp]
    puts "Failed."
    delete_CkHttpResponse $resp

    delete_CkHttp $http
    delete_CkJsonObject $json
    delete_CkStringBuilder $sbResponseBody
    delete_CkJsonObject $jResp
    exit
}

delete_CkHttpResponse $resp

# 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

set productId [CkJsonObject_IntOf $jResp "product.id"]
set productCreatedAt [CkJsonObject_stringOf $jResp "product.createdAt"]
set productUpdatedAt [CkJsonObject_stringOf $jResp "product.updatedAt"]
set productIsVisible [CkJsonObject_BoolOf $jResp "product.isVisible"]
set productVisibility [CkJsonObject_stringOf $jResp "product.visibility"]
set productHasMatrix [CkJsonObject_BoolOf $jResp "product.hasMatrix"]
set productData01 [CkJsonObject_stringOf $jResp "product.data01"]
set productData02 [CkJsonObject_stringOf $jResp "product.data02"]
set productData03 [CkJsonObject_stringOf $jResp "product.data03"]
set productUrl [CkJsonObject_stringOf $jResp "product.url"]
set productTitle [CkJsonObject_stringOf $jResp "product.title"]
set productFulltitle [CkJsonObject_stringOf $jResp "product.fulltitle"]
set productDescription [CkJsonObject_stringOf $jResp "product.description"]
set productContent [CkJsonObject_stringOf $jResp "product.content"]
set productSet [CkJsonObject_BoolOf $jResp "product.set"]
set productBrandResourceId [CkJsonObject_IntOf $jResp "product.brand.resource.id"]
set productBrandResourceUrl [CkJsonObject_stringOf $jResp "product.brand.resource.url"]
set productBrandResourceLink [CkJsonObject_stringOf $jResp "product.brand.resource.link"]
set productCategoriesResourceId [CkJsonObject_BoolOf $jResp "product.categories.resource.id"]
set productCategoriesResourceUrl [CkJsonObject_stringOf $jResp "product.categories.resource.url"]
set productCategoriesResourceLink [CkJsonObject_stringOf $jResp "product.categories.resource.link"]
set productDeliverydateResourceId [CkJsonObject_IntOf $jResp "product.deliverydate.resource.id"]
set productDeliverydateResourceUrl [CkJsonObject_stringOf $jResp "product.deliverydate.resource.url"]
set productDeliverydateResourceLink [CkJsonObject_stringOf $jResp "product.deliverydate.resource.link"]
set productImage [CkJsonObject_BoolOf $jResp "product.image"]
set productImages [CkJsonObject_BoolOf $jResp "product.images"]
set productRelationsResourceId [CkJsonObject_BoolOf $jResp "product.relations.resource.id"]
set productRelationsResourceUrl [CkJsonObject_stringOf $jResp "product.relations.resource.url"]
set productRelationsResourceLink [CkJsonObject_stringOf $jResp "product.relations.resource.link"]
set productMetafieldsResourceId [CkJsonObject_BoolOf $jResp "product.metafields.resource.id"]
set productMetafieldsResourceUrl [CkJsonObject_stringOf $jResp "product.metafields.resource.url"]
set productMetafieldsResourceLink [CkJsonObject_stringOf $jResp "product.metafields.resource.link"]
set productReviewsResourceId [CkJsonObject_BoolOf $jResp "product.reviews.resource.id"]
set productReviewsResourceUrl [CkJsonObject_stringOf $jResp "product.reviews.resource.url"]
set productReviewsResourceLink [CkJsonObject_stringOf $jResp "product.reviews.resource.link"]
set productType [CkJsonObject_BoolOf $jResp "product.type"]
set productAttributesResourceId [CkJsonObject_BoolOf $jResp "product.attributes.resource.id"]
set productAttributesResourceUrl [CkJsonObject_stringOf $jResp "product.attributes.resource.url"]
set productAttributesResourceLink [CkJsonObject_stringOf $jResp "product.attributes.resource.link"]
set productSupplierResourceId [CkJsonObject_IntOf $jResp "product.supplier.resource.id"]
set productSupplierResourceUrl [CkJsonObject_stringOf $jResp "product.supplier.resource.url"]
set productSupplierResourceLink [CkJsonObject_stringOf $jResp "product.supplier.resource.link"]
set productTagsResourceId [CkJsonObject_BoolOf $jResp "product.tags.resource.id"]
set productTagsResourceUrl [CkJsonObject_stringOf $jResp "product.tags.resource.url"]
set productTagsResourceLink [CkJsonObject_stringOf $jResp "product.tags.resource.link"]
set productVariantsResourceId [CkJsonObject_BoolOf $jResp "product.variants.resource.id"]
set productVariantsResourceUrl [CkJsonObject_stringOf $jResp "product.variants.resource.url"]
set productVariantsResourceLink [CkJsonObject_stringOf $jResp "product.variants.resource.link"]
set productMovementsResourceId [CkJsonObject_BoolOf $jResp "product.movements.resource.id"]
set productMovementsResourceUrl [CkJsonObject_stringOf $jResp "product.movements.resource.url"]
set productMovementsResourceLink [CkJsonObject_stringOf $jResp "product.movements.resource.link"]

delete_CkHttp $http
delete_CkJsonObject $json
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jResp

 

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