Chilkat Online Tools

Foxpro / Marketplacer SELLER API / Promotions Query

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loResp

* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')

loHttp.BasicAuth = 1
loHttp.Login = "{{username}}"
loHttp.Password = "{{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}"
* }

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject')
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("query","query PromotionQuery($status: String, $pageSize: Int, $endCursor: String) {" + CHR(10) + "	promotions(status: $status, first: $pageSize, after: $endCursor) {" + CHR(10) + "		totalCount" + CHR(10) + "		pageInfo {" + CHR(10) + "			hasNextPage" + CHR(10) + "			endCursor" + CHR(10) + "		}" + CHR(10) + "		nodes  {" + CHR(10) + "			id" + CHR(10) + "			seller {" + CHR(10) + "				id" + CHR(10) + "				businessName" + CHR(10) + "			}" + CHR(10) + "			name" + CHR(10) + "			teaser" + CHR(10) + "			description" + CHR(10) + "			startDate" + CHR(10) + "			endDate" + CHR(10) + "			minimumSpend" + CHR(10) + "			maximumSpend" + CHR(10) + "			suspended" + CHR(10) + "			discountType" + CHR(10) + "			discountAmount" + CHR(10) + "			freeShipping" + CHR(10) + "			costPercentageBorneByMarketplace" + CHR(10) + "			loyaltyProgramLevels (first: $pageSize, after: $endCursor){" + CHR(10) + "				nodes {" + CHR(10) + "					name" + CHR(10) + "				}" + CHR(10) + "				pageInfo{" + CHR(10) + "					...PageInfoPartial" + CHR(10) + "				}" + CHR(10) + "			}" + CHR(10) + "			freeShippingDomesticOnly" + CHR(10) + "			brandsIncluded (first: $pageSize, after: $endCursor){" + CHR(10) + "				edges {" + CHR(10) + "					node {" + CHR(10) + "						name" + CHR(10) + "					}" + CHR(10) + "				}" + CHR(10) + "				pageInfo{" + CHR(10) + "					...PageInfoPartial" + CHR(10) + "				}" + CHR(10) + "			}" + CHR(10) + "			brandsExcluded (first: $pageSize, after: $endCursor){" + CHR(10) + "				edges {" + CHR(10) + "					node {" + CHR(10) + "						name" + CHR(10) + "					}" + CHR(10) + "				}" + CHR(10) + "				pageInfo{" + CHR(10) + "					...PageInfoPartial" + CHR(10) + "				}" + CHR(10) + "			}" + CHR(10) + "			categoriesIncluded (first: $pageSize, after: $endCursor){" + CHR(10) + "				edges {" + CHR(10) + "					node {" + CHR(10) + "						displayName" + CHR(10) + "					}" + CHR(10) + "				}" + CHR(10) + "				pageInfo{" + CHR(10) + "					...PageInfoPartial" + CHR(10) + "				}" + CHR(10) + "			}" + CHR(10) + "			categoriesExcluded (first: $pageSize, after: $endCursor){" + CHR(10) + "				edges {" + CHR(10) + "					node {" + CHR(10) + "						displayName" + CHR(10) + "					}" + CHR(10) + "				}" + CHR(10) + "			}" + CHR(10) + "			advertsIncluded (first: $pageSize, after: $endCursor){" + CHR(10) + "				edges {" + CHR(10) + "					node {" + CHR(10) + "						description" + CHR(10) + "					}" + CHR(10) + "				}" + CHR(10) + "				pageInfo{" + CHR(10) + "					...PageInfoPartial" + CHR(10) + "				}" + CHR(10) + "			}" + CHR(10) + "			advertsExcluded (first: $pageSize, after: $endCursor) {" + CHR(10) + "				edges {" + CHR(10) + "					node {" + CHR(10) + "						description" + CHR(10) + "					}" + CHR(10) + "				}" + CHR(10) + "				pageInfo{" + CHR(10) + "					...PageInfoPartial" + CHR(10) + "				}" + CHR(10) + "			}" + CHR(10) + "			variantsIncluded (first: $pageSize, after: $endCursor){" + CHR(10) + "				edges {" + CHR(10) + "					node {" + CHR(10) + "						sku" + CHR(10) + "					}" + CHR(10) + "				}" + CHR(10) + "				pageInfo{" + CHR(10) + "					...PageInfoPartial" + CHR(10) + "				}" + CHR(10) + "			}" + CHR(10) + "			variantsExcluded (first: $pageSize, after: $endCursor) {" + CHR(10) + "				edges {" + CHR(10) + "					node {" + CHR(10) + "						sku" + CHR(10) + "					}" + CHR(10) + "				}" + CHR(10) + "				pageInfo{" + CHR(10) + "					...PageInfoPartial" + CHR(10) + "				}" + CHR(10) + "			}" + CHR(10) + "			saleItemsExcluded" + CHR(10) + "		}" + CHR(10) + "	}" + CHR(10) + "}" + CHR(10) + CHR(10) + "fragment PageInfoPartial on PageInfo {" + CHR(10) + "	hasNextPage" + CHR(10) + "	endCursor" + CHR(10) + "}" + CHR(10))
loJson.UpdateString("variables",'{' + CHR(10) + '	"status": "active",' + CHR(10) + '	"pageSize": 10,' + CHR(10) + '	"endCursor": "\CHR(10) + '}')

loHttp.SetRequestHeader("Content-Type","application/json")
loHttp.SetRequestHeader("MARKETPLACER-API-KEY","{{api_key}}")

loResp = loHttp.PostJson3("https://bestfriendbazaar.com/graphql","application/json",loJson)
IF (loHttp.LastMethodSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loJson
    CANCEL
ENDIF

? STR(loResp.StatusCode)
? loResp.BodyStr
RELEASE loResp

RELEASE loHttp
RELEASE loJson

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": [
  ]
}