Sample code for 30+ languages & platforms
B4X

Shopify Receive Count of All Products in a Collection

See more Shopify Examples

Get a count of all products of a given collection

Chilkat B4X Downloads

B4X
Dim success As Boolean = False

Dim rest As ChilkatRest
rest.Initialize("rest")

rest.SetAuthBasic("SHOPIFY_PRIVATE_API_KEY", "SHOPIFY_PRIVATE_API_KEY")

success = rest.Connect("chilkat.myshopify.com", 443, True, True)
If success <> True Then
    Log(rest.LastErrorText)
    Return
End If


Dim sbJson As ChilkatStringBuilder
sbJson.Initialize
success = rest.FullRequestNoBodySb("GET", "/admin/products/count.json?collection_id=841564295 ", sbJson)
If success <> True Then
    Log(rest.LastErrorText)
    Return
End If


If rest.ResponseStatusCode <> 200 Then
    Log("Received error response code: " & rest.ResponseStatusCode)
    Log("Response body:")
    Log(sbJson.GetAsString)
    Return
End If


Dim json As ChilkatJsonObject
json.Initialize
json.LoadSb(sbJson)

'  The following code parses the JSON response.
'  A sample JSON response is shown below the sample code.
Dim count As Int

count = json.IntOf("count")

'  A sample JSON response body that is parsed by the above code:

'  {
'    "count": 1
'  }

Log("Example Completed.")