(Unicode C++) Shopify Receive Count of All Products in a Collection
Get a count of all products of a given collection
#include <CkRestW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.h>
void ChilkatSample(void)
{
CkRestW rest;
bool success;
rest.SetAuthBasic(L"SHOPIFY_PRIVATE_API_KEY",L"SHOPIFY_PRIVATE_API_KEY");
success = rest.Connect(L"chilkat.myshopify.com",443,true,true);
if (success != true) {
wprintf(L"%s\n",rest.lastErrorText());
return;
}
CkStringBuilderW sbJson;
success = rest.FullRequestNoBodySb(L"GET",L"/admin/products/count.json?collection_id=841564295 ",sbJson);
if (success != true) {
wprintf(L"%s\n",rest.lastErrorText());
return;
}
if (rest.get_ResponseStatusCode() != 200) {
wprintf(L"Received error response code: %d\n",rest.get_ResponseStatusCode());
wprintf(L"Response body:\n");
wprintf(L"%s\n",sbJson.getAsString());
return;
}
CkJsonObjectW json;
json.LoadSb(sbJson);
// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
int count;
count = json.IntOf(L"count");
// A sample JSON response body that is parsed by the above code:
// {
// "count": 1
// }
wprintf(L"Example Completed.\n");
}
|