Back to Collection Items
#include <CkHttpW.h>
#include <CkJsonObjectW.h>
#include <CkHttpResponseW.h>
void ChilkatSample(void)
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttpW http;
bool success;
http.put_BasicAuth(true);
http.put_Login(L"{{username}}");
http.put_Password(L"{{password}}");
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "query": "query PromotionQuery($status: String, $pageSize: Int, $endCursor: String) {\n\tpromotions(status: $status, first: $pageSize, after: $endCursor) {\n\t\ttotalCount\n\t\tpageInfo {\n\t\t\thasNextPage\n\t\t\tendCursor\n\t\t}\n\t\tnodes {\n\t\t\tid\n\t\t\tseller {\n\t\t\t\tid\n\t\t\t\tbusinessName\n\t\t\t}\n\t\t\tname\n\t\t\tteaser\n\t\t\tdescription\n\t\t\tstartDate\n\t\t\tendDate\n\t\t\tminimumSpend\n\t\t\tmaximumSpend\n\t\t\tsuspended\n\t\t\tdiscountType\n\t\t\tdiscountAmount\n\t\t\tfreeShipping\n\t\t\tcostPercentageBorneByMarketplace\n\t\t\tloyaltyProgramLevels (first: $pageSize, after: $endCursor){\n\t\t\t\tnodes {\n\t\t\t\t\tname\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tfreeShippingDomesticOnly\n\t\t\tbrandsIncluded (first: $pageSize, after: $endCursor){\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tname\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tbrandsExcluded (first: $pageSize, after: $endCursor){\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tname\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tcategoriesIncluded (first: $pageSize, after: $endCursor){\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tdisplayName\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tcategoriesExcluded (first: $pageSize, after: $endCursor){\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tdisplayName\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tadvertsIncluded (first: $pageSize, after: $endCursor){\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tdescription\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tadvertsExcluded (first: $pageSize, after: $endCursor) {\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tdescription\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tvariantsIncluded (first: $pageSize, after: $endCursor){\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tsku\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tvariantsExcluded (first: $pageSize, after: $endCursor) {\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tsku\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tsaleItemsExcluded\n\t\t}\n\t}\n}\n\nfragment PageInfoPartial on PageInfo {\n\thasNextPage\n\tendCursor\n}\n",
// "variables": "{\n\t\"status\": \"active\",\n\t\"pageSize\": 10,\n\t\"endCursor\": \"\"\n}"
// }
CkJsonObjectW json;
json.UpdateString(L"query",L"query PromotionQuery($status: String, $pageSize: Int, $endCursor: String) {\n promotions(status: $status, first: $pageSize, after: $endCursor) {\n totalCount\n pageInfo {\n hasNextPage\n endCursor\n }\n nodes {\n id\n seller {\n id\n businessName\n }\n name\n teaser\n description\n startDate\n endDate\n minimumSpend\n maximumSpend\n suspended\n discountType\n discountAmount\n freeShipping\n costPercentageBorneByMarketplace\n loyaltyProgramLevels (first: $pageSize, after: $endCursor){\n nodes {\n name\n }\n pageInfo{\n ...PageInfoPartial\n }\n }\n freeShippingDomesticOnly\n brandsIncluded (first: $pageSize, after: $endCursor){\n edges {\n node {\n name\n }\n }\n pageInfo{\n ...PageInfoPartial\n }\n }\n brandsExcluded (first: $pageSize, after: $endCursor){\n edges {\n node {\n name\n }\n }\n pageInfo{\n ...PageInfoPartial\n }\n }\n categoriesIncluded (first: $pageSize, after: $endCursor){\n edges {\n node {\n displayName\n }\n }\n pageInfo{\n ...PageInfoPartial\n }\n }\n categoriesExcluded (first: $pageSize, after: $endCursor){\n edges {\n node {\n displayName\n }\n }\n }\n advertsIncluded (first: $pageSize, after: $endCursor){\n edges {\n node {\n description\n }\n }\n pageInfo{\n ...PageInfoPartial\n }\n }\n advertsExcluded (first: $pageSize, after: $endCursor) {\n edges {\n node {\n description\n }\n }\n pageInfo{\n ...PageInfoPartial\n }\n }\n variantsIncluded (first: $pageSize, after: $endCursor){\n edges {\n node {\n sku\n }\n }\n pageInfo{\n ...PageInfoPartial\n }\n }\n variantsExcluded (first: $pageSize, after: $endCursor) {\n edges {\n node {\n sku\n }\n }\n pageInfo{\n ...PageInfoPartial\n }\n }\n saleItemsExcluded\n }\n }\n}\n\nfragment PageInfoPartial on PageInfo {\n hasNextPage\n endCursor\n}\n");
json.UpdateString(L"variables",L"{\n \"status\": \"active\",\n \"pageSize\": 10,\n \"endCursor\": \"\"\n}");
http.SetRequestHeader(L"Content-Type",L"application/json");
http.SetRequestHeader(L"MARKETPLACER-API-KEY",L"{{api_key}}");
CkHttpResponseW *resp = http.PostJson3(L"https://bestfriendbazaar.com/graphql",L"application/json",json);
if (http.get_LastMethodSuccess() == false) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
wprintf(L"%d\n",resp->get_StatusCode());
wprintf(L"%s\n",resp->bodyStr());
delete resp;
}
Curl Command
curl -X POST
-u '{{username}}:{{password}}'
-H "MARKETPLACER-API-KEY: {{api_key}}"
-H "Content-Type: application/json"
--data-raw '{"query":"query PromotionQuery($status: String, $pageSize: Int, $endCursor: String) {\n\tpromotions(status: $status, first: $pageSize, after: $endCursor) {\n\t\ttotalCount\n\t\tpageInfo {\n\t\t\thasNextPage\n\t\t\tendCursor\n\t\t}\n\t\tnodes {\n\t\t\tid\n\t\t\tseller {\n\t\t\t\tid\n\t\t\t\tbusinessName\n\t\t\t}\n\t\t\tname\n\t\t\tteaser\n\t\t\tdescription\n\t\t\tstartDate\n\t\t\tendDate\n\t\t\tminimumSpend\n\t\t\tmaximumSpend\n\t\t\tsuspended\n\t\t\tdiscountType\n\t\t\tdiscountAmount\n\t\t\tfreeShipping\n\t\t\tcostPercentageBorneByMarketplace\n\t\t\tloyaltyProgramLevels (first: $pageSize, after: $endCursor){\n\t\t\t\tnodes {\n\t\t\t\t\tname\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tfreeShippingDomesticOnly\n\t\t\tbrandsIncluded (first: $pageSize, after: $endCursor){\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tname\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tbrandsExcluded (first: $pageSize, after: $endCursor){\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tname\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tcategoriesIncluded (first: $pageSize, after: $endCursor){\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tdisplayName\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tcategoriesExcluded (first: $pageSize, after: $endCursor){\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tdisplayName\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tadvertsIncluded (first: $pageSize, after: $endCursor){\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tdescription\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tadvertsExcluded (first: $pageSize, after: $endCursor) {\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tdescription\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tvariantsIncluded (first: $pageSize, after: $endCursor){\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tsku\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tvariantsExcluded (first: $pageSize, after: $endCursor) {\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tsku\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tsaleItemsExcluded\n\t\t}\n\t}\n}\n\nfragment PageInfoPartial on PageInfo {\n\thasNextPage\n\tendCursor\n}\n","variables":"{\n\t\"status\": \"active\",\n\t\"pageSize\": 10,\n\t\"endCursor\": \"\"\n}"}'
https://bestfriendbazaar.com/graphql
Postman Collection Item JSON
{
"name": "Promotions Query",
"request": {
"method": "POST",
"header": [
{
"key": "MARKETPLACER-API-KEY",
"value": "{{api_key}}",
"type": "text"
},
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "graphql",
"graphql": {
"query": "query PromotionQuery($status: String, $pageSize: Int, $endCursor: String) {\n\tpromotions(status: $status, first: $pageSize, after: $endCursor) {\n\t\ttotalCount\n\t\tpageInfo {\n\t\t\thasNextPage\n\t\t\tendCursor\n\t\t}\n\t\tnodes {\n\t\t\tid\n\t\t\tseller {\n\t\t\t\tid\n\t\t\t\tbusinessName\n\t\t\t}\n\t\t\tname\n\t\t\tteaser\n\t\t\tdescription\n\t\t\tstartDate\n\t\t\tendDate\n\t\t\tminimumSpend\n\t\t\tmaximumSpend\n\t\t\tsuspended\n\t\t\tdiscountType\n\t\t\tdiscountAmount\n\t\t\tfreeShipping\n\t\t\tcostPercentageBorneByMarketplace\n\t\t\tloyaltyProgramLevels (first: $pageSize, after: $endCursor){\n\t\t\t\tnodes {\n\t\t\t\t\tname\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tfreeShippingDomesticOnly\n\t\t\tbrandsIncluded (first: $pageSize, after: $endCursor){\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tname\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tbrandsExcluded (first: $pageSize, after: $endCursor){\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tname\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tcategoriesIncluded (first: $pageSize, after: $endCursor){\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tdisplayName\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tcategoriesExcluded (first: $pageSize, after: $endCursor){\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tdisplayName\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tadvertsIncluded (first: $pageSize, after: $endCursor){\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tdescription\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tadvertsExcluded (first: $pageSize, after: $endCursor) {\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tdescription\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tvariantsIncluded (first: $pageSize, after: $endCursor){\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tsku\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tvariantsExcluded (first: $pageSize, after: $endCursor) {\n\t\t\t\tedges {\n\t\t\t\t\tnode {\n\t\t\t\t\t\tsku\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tpageInfo{\n\t\t\t\t\t...PageInfoPartial\n\t\t\t\t}\n\t\t\t}\n\t\t\tsaleItemsExcluded\n\t\t}\n\t}\n}\n\nfragment PageInfoPartial on PageInfo {\n\thasNextPage\n\tendCursor\n}\n",
"variables": "{\n\t\"status\": \"active\",\n\t\"pageSize\": 10,\n\t\"endCursor\": \"\"\n}"
}
},
"url": {
"raw": "{{base_url}}",
"host": [
"{{base_url}}"
],
"path": null
},
"description": null
},
"response": [
]
}