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

.NET Core C# 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

 

 

 

(.NET Core C#) WiX Create Product

Creates a new product.

Note: If you get a 403 error response, try refreshing the access token.

For more information, see https://dev.wix.com/api/rest/wix-stores/catalog/product/create-product

Chilkat .NET Downloads

Chilkat .NET Assemblies

Chilkat for .NET Core

Chilkat for Mono

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

Chilkat.Http http = new Chilkat.Http();
bool success;

// Implements the following CURL command:

// curl -X POST \
//    'https://www.wixapis.com/stores/v1/products' \
//     --data-binary '{
//                      "product": {
//                        "name": "T-shirt",
//                        "productType": "physical",
//                        "priceData": {
//                          "price": 10.5
//                        },
//                        "description": "nice summer t-shirt",
//                        "sku": "123df",
//                        "visible": false,
//                        "weight": 0.2,
//                        "discount": {
//                        	"type": "AMOUNT",
//                        	"value": 1
//                        },
//                        "manageVariants": true,
//                        "productOptions": [
//                          {
//                            "name": "Size",
//                            "choices": [
//                              {
//                                "value": "S",
//                                "description": "S"
//                              },
//                              {
//                                "value": "L",
//                                "description": "L"
//                              }
//                            ]
//                          }
//                        ]
//                      }
//                    }' \
//    -H 'Content-Type: application/json' \
//    -H 'Authorization: <AUTH>'

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

// 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": {
//     "name": "T-shirt",
//     "productType": "physical",
//     "priceData": {
//       "price": 10.5
//     },
//     "description": "nice summer t-shirt",
//     "sku": "123df",
//     "visible": false,
//     "weight": 0.2,
//     "discount": {
//       "type": "AMOUNT",
//       "value": 1
//     },
//     "manageVariants": true,
//     "productOptions": [
//       {
//         "name": "Size",
//         "choices": [
//           {
//             "value": "S",
//             "description": "S"
//           },
//           {
//             "value": "L",
//             "description": "L"
//           }
//         ]
//       }
//     ]
//   }
// }

Chilkat.JsonObject json = new Chilkat.JsonObject();
json.UpdateString("product.name","T-shirt");
json.UpdateString("product.productType","physical");
json.UpdateNumber("product.priceData.price","10.5");
json.UpdateString("product.description","nice summer t-shirt");
json.UpdateString("product.sku","123df");
json.UpdateBool("product.visible",false);
json.UpdateNumber("product.weight","0.2");
json.UpdateString("product.discount.type","AMOUNT");
json.UpdateInt("product.discount.value",1);
json.UpdateBool("product.manageVariants",true);
json.UpdateString("product.productOptions[0].name","Size");
json.UpdateString("product.productOptions[0].choices[0].value","S");
json.UpdateString("product.productOptions[0].choices[0].description","S");
json.UpdateString("product.productOptions[0].choices[1].value","L");
json.UpdateString("product.productOptions[0].choices[1].description","L");

http.AuthToken = "ACCESS_TOKEN";
http.SetRequestHeader("Content-Type","application/json");

Chilkat.HttpResponse resp = http.PostJson3("https://www.wixapis.com/stores/v1/products","application/json",json);
if (http.LastMethodSuccess == false) {
    Debug.WriteLine(http.LastErrorText);
    return;
}

Chilkat.StringBuilder sbResponseBody = new Chilkat.StringBuilder();
resp.GetBodySb(sbResponseBody);
Chilkat.JsonObject jResp = new Chilkat.JsonObject();
jResp.LoadSb(sbResponseBody);
jResp.EmitCompact = false;

Debug.WriteLine("Response Body:");
Debug.WriteLine(jResp.Emit());

int respStatusCode = resp.StatusCode;
Debug.WriteLine("Response Status Code = " + Convert.ToString(respStatusCode));
if (respStatusCode >= 400) {
    Debug.WriteLine("Response Header:");
    Debug.WriteLine(resp.Header);
    Debug.WriteLine("Failed.");

    return;
}

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

// {
//   "product": {
//     "id": "e28e4ddd-6ed0-4098-a5e5-cf4bd9c4f7b5",
//     "name": "T-shirt",
//     "slug": "t-shirt-1",
//     "visible": false,
//     "productType": "physical",
//     "description": "nice summer t-shirt",
//     "stock": {
//       "trackInventory": false,
//       "inStock": true
//     },
//     "price": {
//       "currency": "ILS",
//       "price": 10.5,
//       "discountedPrice": 9.5,
//       "formatted": {
//         "price": "10.50",
//         "discountedPrice": "9.50"
//       }
//     },
//     "priceData": {
//       "currency": "ILS",
//       "price": 10.5,
//       "discountedPrice": 9.5,
//       "formatted": {
//         "price": "10.50",
//         "discountedPrice": "9.50"
//       }
//     },
//     "additionalInfoSections": [
//     ],
//     "ribbons": [
//     ],
//     "media": {
//       "items": [
//       ]
//     },
//     "customTextFields": [
//     ],
//     "manageVariants": true,
//     "productOptions": [
//       {
//         "optionType": "drop_down",
//         "name": "Size",
//         "choices": [
//           {
//             "value": "S",
//             "description": "S",
//             "inStock": true,
//             "visible": true
//           },
//           {
//             "value": "L",
//             "description": "L",
//             "inStock": true,
//             "visible": true
//           }
//         ]
//       }
//     ],
//     "productPageUrl": {
//       "base": "https://www.itsjusttooeasy123.com/",
//       "path": "/product-page/t-shirt-1"
//     },
//     "numericId": "1567588455405000",
//     "inventoryItemId": "1d71b222-912f-bf67-5a1a-30b4263b084a",
//     "discount": {
//       "type": "AMOUNT",
//       "value": 1
//     },
//     "collectionIds": [
//     ],
//     "variants": [
//       {
//         "id": "00000000-0000-0001-0005-93fc95e0514a",
//         "choices": {
//           "Size": "S"
//         },
//         "variant": {
//           "priceData": {
//             "currency": "ILS",
//             "price": 10.5,
//             "discountedPrice": 9.5,
//             "formatted": {
//               "price": "10.50",
//               "discountedPrice": "9.50"
//             }
//           },
//           "weight": 10,
//           "visible": true
//         }
//       },
//       {
//         "id": "00000000-0000-0002-0005-93fc95e0514a",
//         "choices": {
//           "Size": "L"
//         },
//         "variant": {
//           "priceData": {
//             "currency": "ILS",
//             "price": 10.5,
//             "discountedPrice": 9.5,
//             "formatted": {
//               "price": "10.50",
//               "discountedPrice": "9.50"
//             }
//           },
//           "visible": true
//         }
//       }
//     ]
//   }
// }

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

string optionType;
string name;
int j;
int count_j;
string value;
string description;
bool inStock;
bool visible;
string id;
string choicesSize;
string variantPriceDataCurrency;
string variantPriceDataPrice;
string variantPriceDataDiscountedPrice;
string variantPriceDataFormattedPrice;
string variantPriceDataFormattedDiscountedPrice;
int variantWeight;
bool variantVisible;

string productId = jResp.StringOf("product.id");
string productName = jResp.StringOf("product.name");
string productSlug = jResp.StringOf("product.slug");
bool productVisible = jResp.BoolOf("product.visible");
string productProductType = jResp.StringOf("product.productType");
string productDescription = jResp.StringOf("product.description");
bool productStockTrackInventory = jResp.BoolOf("product.stock.trackInventory");
bool productStockInStock = jResp.BoolOf("product.stock.inStock");
string productPriceCurrency = jResp.StringOf("product.price.currency");
string productPricePrice = jResp.StringOf("product.price.price");
string productPriceDiscountedPrice = jResp.StringOf("product.price.discountedPrice");
string productPriceFormattedPrice = jResp.StringOf("product.price.formatted.price");
string productPriceFormattedDiscountedPrice = jResp.StringOf("product.price.formatted.discountedPrice");
string productPriceDataCurrency = jResp.StringOf("product.priceData.currency");
string productPriceDataPrice = jResp.StringOf("product.priceData.price");
string productPriceDataDiscountedPrice = jResp.StringOf("product.priceData.discountedPrice");
string productPriceDataFormattedPrice = jResp.StringOf("product.priceData.formatted.price");
string productPriceDataFormattedDiscountedPrice = jResp.StringOf("product.priceData.formatted.discountedPrice");
bool productManageVariants = jResp.BoolOf("product.manageVariants");
string productProductPageUrlBase = jResp.StringOf("product.productPageUrl.base");
string productProductPageUrlPath = jResp.StringOf("product.productPageUrl.path");
string productNumericId = jResp.StringOf("product.numericId");
string productInventoryItemId = jResp.StringOf("product.inventoryItemId");
string productDiscountType = jResp.StringOf("product.discount.type");
int productDiscountValue = jResp.IntOf("product.discount.value");
int i = 0;
int count_i = jResp.SizeOfArray("product.additionalInfoSections");
while (i < count_i) {
    jResp.I = i;
    i = i + 1;
}

i = 0;
count_i = jResp.SizeOfArray("product.ribbons");
while (i < count_i) {
    jResp.I = i;
    i = i + 1;
}

i = 0;
count_i = jResp.SizeOfArray("product.media.items");
while (i < count_i) {
    jResp.I = i;
    i = i + 1;
}

i = 0;
count_i = jResp.SizeOfArray("product.customTextFields");
while (i < count_i) {
    jResp.I = i;
    i = i + 1;
}

i = 0;
count_i = jResp.SizeOfArray("product.productOptions");
while (i < count_i) {
    jResp.I = i;
    optionType = jResp.StringOf("product.productOptions[i].optionType");
    name = jResp.StringOf("product.productOptions[i].name");
    j = 0;
    count_j = jResp.SizeOfArray("product.productOptions[i].choices");
    while (j < count_j) {
        jResp.J = j;
        value = jResp.StringOf("product.productOptions[i].choices[j].value");
        description = jResp.StringOf("product.productOptions[i].choices[j].description");
        inStock = jResp.BoolOf("product.productOptions[i].choices[j].inStock");
        visible = jResp.BoolOf("product.productOptions[i].choices[j].visible");
        j = j + 1;
    }

    i = i + 1;
}

i = 0;
count_i = jResp.SizeOfArray("product.collectionIds");
while (i < count_i) {
    jResp.I = i;
    i = i + 1;
}

i = 0;
count_i = jResp.SizeOfArray("product.variants");
while (i < count_i) {
    jResp.I = i;
    id = jResp.StringOf("product.variants[i].id");
    choicesSize = jResp.StringOf("product.variants[i].choices.Size");
    variantPriceDataCurrency = jResp.StringOf("product.variants[i].variant.priceData.currency");
    variantPriceDataPrice = jResp.StringOf("product.variants[i].variant.priceData.price");
    variantPriceDataDiscountedPrice = jResp.StringOf("product.variants[i].variant.priceData.discountedPrice");
    variantPriceDataFormattedPrice = jResp.StringOf("product.variants[i].variant.priceData.formatted.price");
    variantPriceDataFormattedDiscountedPrice = jResp.StringOf("product.variants[i].variant.priceData.formatted.discountedPrice");
    variantWeight = jResp.IntOf("product.variants[i].variant.weight");
    variantVisible = jResp.BoolOf("product.variants[i].variant.visible");
    i = i + 1;
}


 

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