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
(DataFlex) Shopify Query a variant for its inventory item IDQuery a product variant to find the ID of its inventory item. For more information, see https://shopify.dev/tutorials/manage-product-inventory-with-admin-api#retrieve-the-inventory-levels-for-a-product-variant
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp Variant vResp Handle hoResp Handle hoJsonResponse Boolean iSuccess Integer iId Integer iProduct_id String sTitle Integer iInventory_item_id String sAdmin_graphql_api_id String sTemp1 Integer iTemp1 Boolean bTemp1 // This example requires 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 Set ComLogin Of hoHttp To "SHOPIFY_PRIVATE_API_KEY" Set ComPassword Of hoHttp To "SHOPIFY_PRIVATE_API_KEY" Set ComAccept Of hoHttp To "application/json" Get ComQuickRequest Of hoHttp "GET" "https://{shop}.myshopify.com/admin/api/2020-04/products/{product_id}/variants/{variant_id}.json" 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 <> True) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End Get ComStatusCode Of hoResp To iTemp1 Showln "Response Status Code: " iTemp1 Get Create (RefClass(cComChilkatJsonObject)) To hoJsonResponse If (Not(IsComObjectCreated(hoJsonResponse))) Begin Send CreateComObject of hoJsonResponse End Get ComBodyStr Of hoResp To sTemp1 Get ComLoad Of hoJsonResponse sTemp1 To iSuccess Set ComEmitCompact Of hoJsonResponse To False Get ComEmit Of hoJsonResponse To sTemp1 Showln sTemp1 Get ComStatusCode Of hoResp To iTemp1 If (iTemp1 <> 200) Begin Showln "Failed." Send Destroy of hoResp Procedure_Return End Send Destroy of hoResp // Sample output... // (See the parsing code below..) // // Use the this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON // { // "id": 12195009364024, // "product_id": 1321541042232, // "title": "xs", // ... // "inventory_item_id": 12250274365496, // ... // "admin_graphql_api_id": "gid://shopify/ProductVariant/12195009364024" // } // Get ComIntOf Of hoJsonResponse "id" To iId Get ComIntOf Of hoJsonResponse "product_id" To iProduct_id Get ComStringOf Of hoJsonResponse "title" To sTitle Get ComIntOf Of hoJsonResponse "inventory_item_id" To iInventory_item_id Get ComStringOf Of hoJsonResponse "admin_graphql_api_id" To sAdmin_graphql_api_id End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.