(Chilkat2-Python) Shopify Receive Count of All Products in a Collection
Get a count of all products of a given collection
import sys
import chilkat2
rest = chilkat2.Rest()
rest.SetAuthBasic("SHOPIFY_PRIVATE_API_KEY","SHOPIFY_PRIVATE_API_KEY")
success = rest.Connect("chilkat.myshopify.com",443,True,True)
if (success != True):
print(rest.LastErrorText)
sys.exit()
sbJson = chilkat2.StringBuilder()
success = rest.FullRequestNoBodySb("GET","/admin/products/count.json?collection_id=841564295 ",sbJson)
if (success != True):
print(rest.LastErrorText)
sys.exit()
if (rest.ResponseStatusCode != 200):
print("Received error response code: " + str(rest.ResponseStatusCode))
print("Response body:")
print(sbJson.GetAsString())
sys.exit()
json = chilkat2.JsonObject()
json.LoadSb(sbJson)
# The following code parses the JSON response.
# A sample JSON response is shown below the sample code.
count = json.IntOf("count")
# A sample JSON response body that is parsed by the above code:
# {
# "count": 1
# }
print("Example Completed.")
|