Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) Lightspeed - Create a ProductCreate a new product based on the given parameters. For more information, see https://developers.lightspeedhq.com/ecom/endpoints/product/#post-create-a-product
integer li_rc oleobject loo_Http integer li_Success oleobject loo_Json oleobject loo_Resp oleobject loo_SbResponseBody oleobject loo_JResp integer li_RespStatusCode integer li_ProductId string ls_ProductCreatedAt string ls_ProductUpdatedAt integer li_ProductIsVisible string ls_ProductVisibility integer li_ProductHasMatrix string ls_ProductData01 string ls_ProductData02 string ls_ProductData03 string ls_ProductUrl string ls_ProductTitle string ls_ProductFulltitle string ls_ProductDescription string ls_ProductContent integer li_ProductSet integer li_ProductBrandResourceId string ls_ProductBrandResourceUrl string ls_ProductBrandResourceLink integer li_ProductCategoriesResourceId string ls_ProductCategoriesResourceUrl string ls_ProductCategoriesResourceLink integer li_ProductDeliverydateResourceId string ls_ProductDeliverydateResourceUrl string ls_ProductDeliverydateResourceLink integer li_ProductImage integer li_ProductImages integer li_ProductRelationsResourceId string ls_ProductRelationsResourceUrl string ls_ProductRelationsResourceLink integer li_ProductMetafieldsResourceId string ls_ProductMetafieldsResourceUrl string ls_ProductMetafieldsResourceLink integer li_ProductReviewsResourceId string ls_ProductReviewsResourceUrl string ls_ProductReviewsResourceLink integer li_ProductType integer li_ProductAttributesResourceId string ls_ProductAttributesResourceUrl string ls_ProductAttributesResourceLink integer li_ProductSupplierResourceId string ls_ProductSupplierResourceUrl string ls_ProductSupplierResourceLink integer li_ProductTagsResourceId string ls_ProductTagsResourceUrl string ls_ProductTagsResourceLink integer li_ProductVariantsResourceId string ls_ProductVariantsResourceUrl string ls_ProductVariantsResourceLink integer li_ProductMovementsResourceId string ls_ProductMovementsResourceUrl string ls_ProductMovementsResourceLink // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. 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 // 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 loo_Http.Login = "API_KEY" loo_Http.Password = "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 // } // } loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") loo_Json.UpdateString("product.visibility","visible") loo_Json.UpdateString("product.data01","") loo_Json.UpdateString("product.data02","") loo_Json.UpdateString("product.data03","") loo_Json.UpdateString("product.title","Lookin Sharp T-Shirt") loo_Json.UpdateString("product.fulltitle","Lookin Sharp T-Shirt") loo_Json.UpdateString("product.description","Description of the Lookin Sharp T-Shirt") loo_Json.UpdateString("product.content","Long Description of the Lookin Sharp T-Shirt") loo_Json.UpdateInt("product.deliverydate",6488) loo_Json.UpdateInt("product.supplier",78794) loo_Json.UpdateInt("product.brand",1171202) loo_Http.SetRequestHeader("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/ loo_Resp = loo_Http.PostJson3("https://api.webshopapp.com/en/products.json","application/json",loo_Json) if loo_Http.LastMethodSuccess = 0 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_Json return end if loo_SbResponseBody = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder") loo_Resp.GetBodySb(loo_SbResponseBody) loo_JResp = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject") loo_JResp.LoadSb(loo_SbResponseBody) loo_JResp.EmitCompact = 0 Write-Debug "Response Body:" Write-Debug loo_JResp.Emit() li_RespStatusCode = loo_Resp.StatusCode Write-Debug "Response Status Code = " + string(li_RespStatusCode) if li_RespStatusCode >= 400 then Write-Debug "Response Header:" Write-Debug loo_Resp.Header Write-Debug "Failed." destroy loo_Resp destroy loo_Http destroy loo_Json destroy loo_SbResponseBody destroy loo_JResp return end if destroy loo_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 li_ProductId = loo_JResp.IntOf("product.id") ls_ProductCreatedAt = loo_JResp.StringOf("product.createdAt") ls_ProductUpdatedAt = loo_JResp.StringOf("product.updatedAt") li_ProductIsVisible = loo_JResp.BoolOf("product.isVisible") ls_ProductVisibility = loo_JResp.StringOf("product.visibility") li_ProductHasMatrix = loo_JResp.BoolOf("product.hasMatrix") ls_ProductData01 = loo_JResp.StringOf("product.data01") ls_ProductData02 = loo_JResp.StringOf("product.data02") ls_ProductData03 = loo_JResp.StringOf("product.data03") ls_ProductUrl = loo_JResp.StringOf("product.url") ls_ProductTitle = loo_JResp.StringOf("product.title") ls_ProductFulltitle = loo_JResp.StringOf("product.fulltitle") ls_ProductDescription = loo_JResp.StringOf("product.description") ls_ProductContent = loo_JResp.StringOf("product.content") li_ProductSet = loo_JResp.BoolOf("product.set") li_ProductBrandResourceId = loo_JResp.IntOf("product.brand.resource.id") ls_ProductBrandResourceUrl = loo_JResp.StringOf("product.brand.resource.url") ls_ProductBrandResourceLink = loo_JResp.StringOf("product.brand.resource.link") li_ProductCategoriesResourceId = loo_JResp.BoolOf("product.categories.resource.id") ls_ProductCategoriesResourceUrl = loo_JResp.StringOf("product.categories.resource.url") ls_ProductCategoriesResourceLink = loo_JResp.StringOf("product.categories.resource.link") li_ProductDeliverydateResourceId = loo_JResp.IntOf("product.deliverydate.resource.id") ls_ProductDeliverydateResourceUrl = loo_JResp.StringOf("product.deliverydate.resource.url") ls_ProductDeliverydateResourceLink = loo_JResp.StringOf("product.deliverydate.resource.link") li_ProductImage = loo_JResp.BoolOf("product.image") li_ProductImages = loo_JResp.BoolOf("product.images") li_ProductRelationsResourceId = loo_JResp.BoolOf("product.relations.resource.id") ls_ProductRelationsResourceUrl = loo_JResp.StringOf("product.relations.resource.url") ls_ProductRelationsResourceLink = loo_JResp.StringOf("product.relations.resource.link") li_ProductMetafieldsResourceId = loo_JResp.BoolOf("product.metafields.resource.id") ls_ProductMetafieldsResourceUrl = loo_JResp.StringOf("product.metafields.resource.url") ls_ProductMetafieldsResourceLink = loo_JResp.StringOf("product.metafields.resource.link") li_ProductReviewsResourceId = loo_JResp.BoolOf("product.reviews.resource.id") ls_ProductReviewsResourceUrl = loo_JResp.StringOf("product.reviews.resource.url") ls_ProductReviewsResourceLink = loo_JResp.StringOf("product.reviews.resource.link") li_ProductType = loo_JResp.BoolOf("product.type") li_ProductAttributesResourceId = loo_JResp.BoolOf("product.attributes.resource.id") ls_ProductAttributesResourceUrl = loo_JResp.StringOf("product.attributes.resource.url") ls_ProductAttributesResourceLink = loo_JResp.StringOf("product.attributes.resource.link") li_ProductSupplierResourceId = loo_JResp.IntOf("product.supplier.resource.id") ls_ProductSupplierResourceUrl = loo_JResp.StringOf("product.supplier.resource.url") ls_ProductSupplierResourceLink = loo_JResp.StringOf("product.supplier.resource.link") li_ProductTagsResourceId = loo_JResp.BoolOf("product.tags.resource.id") ls_ProductTagsResourceUrl = loo_JResp.StringOf("product.tags.resource.url") ls_ProductTagsResourceLink = loo_JResp.StringOf("product.tags.resource.link") li_ProductVariantsResourceId = loo_JResp.BoolOf("product.variants.resource.id") ls_ProductVariantsResourceUrl = loo_JResp.StringOf("product.variants.resource.url") ls_ProductVariantsResourceLink = loo_JResp.StringOf("product.variants.resource.link") li_ProductMovementsResourceId = loo_JResp.BoolOf("product.movements.resource.id") ls_ProductMovementsResourceUrl = loo_JResp.StringOf("product.movements.resource.url") ls_ProductMovementsResourceLink = loo_JResp.StringOf("product.movements.resource.link") destroy loo_Http destroy loo_Json destroy loo_SbResponseBody destroy loo_JResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.