Chilkat Online Tools

VB6 / Marketplacer SELLER API / advertSearch (Search by Seller Ids)

Back to Collection Items

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

Dim http As New ChilkatHttp
Dim success As Long

http.BasicAuth = 1
http.Login = "{{username}}"
http.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 ProductSearchBySellerId(\n\t$sellerIds: [ID!]\n\t$advertPageSize: Int\n\t$advertEndCursor: String\n\t$variantPageSize: Int\n\t$variantEndCursor: String\n) {\n\tadvertSearch(attributes: { sellerIds: $sellerIds }) {\n\t\tadverts(first: $advertPageSize, after: $advertEndCursor) {\n\t\t\ttotalCount\n\t\t\tpageInfo {\n\t\t\t\t...PageInfoPartial\n\t\t\t}\n\t\t\tedges {\n\t\t\t\tnode {\n\t\t\t\t\tid\n\t\t\t\t\tpriceUnit\n\t\t\t\t\ttitle\n\t\t\t\t\tseller {\n\t\t\t\t\t\tbusinessName\n\t\t\t\t\t}\n\n\t\t\t\t\tvariants(first: $variantPageSize, after: $variantEndCursor) {\n\t\t\t\t\t\ttotalCount\n\t\t\t\t\t\tpageInfo {\n\t\t\t\t\t\t\t...PageInfoPartial\n\t\t\t\t\t\t}\n\t\t\t\t\t\tedges {\n\t\t\t\t\t\t\tnode {\n\t\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\t\tlowestPrice\n\t\t\t\t\t\t\t\tcountOnHand\n\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfragment PageInfoPartial on PageInfo {\n\thasNextPage\n\tendCursor\n}",
'   "variables": "{\n\t\"advertPageSize\": 50,\n\t\"advertEndCursor\": null,\n\t\"variantPageSize\": 5,\n\t\"variantEndCursor\": null,\n\t\"sellerIds\": [\n\t\t\"U2VsbGVyLTY2MDExOQ==\",\n\t\t\"U2VsbGVyLTcw\"\n\t]\n}"
' }

Dim json As New ChilkatJsonObject
success = json.UpdateString("query","query ProductSearchBySellerId(" & vbLf & "	$sellerIds: [ID!]" & vbLf & "	$advertPageSize: Int" & vbLf & "	$advertEndCursor: String" & vbLf & "	$variantPageSize: Int" & vbLf & "	$variantEndCursor: String" & vbLf & ") {" & vbLf & "	advertSearch(attributes: { sellerIds: $sellerIds }) {" & vbLf & "		adverts(first: $advertPageSize, after: $advertEndCursor) {" & vbLf & "			totalCount" & vbLf & "			pageInfo {" & vbLf & "				...PageInfoPartial" & vbLf & "			}" & vbLf & "			edges {" & vbLf & "				node {" & vbLf & "					id" & vbLf & "					priceUnit" & vbLf & "					title" & vbLf & "					seller {" & vbLf & "						businessName" & vbLf & "					}" & vbLf & vbLf & "					variants(first: $variantPageSize, after: $variantEndCursor) {" & vbLf & "						totalCount" & vbLf & "						pageInfo {" & vbLf & "							...PageInfoPartial" & vbLf & "						}" & vbLf & "						edges {" & vbLf & "							node {" & vbLf & "								id" & vbLf & "								lowestPrice" & vbLf & "								countOnHand" & vbLf & "								label" & vbLf & "							}" & vbLf & "						}" & vbLf & "					}" & vbLf & "				}" & vbLf & "			}" & vbLf & "		}" & vbLf & "	}" & vbLf & "}" & vbLf & vbLf & "fragment PageInfoPartial on PageInfo {" & vbLf & "	hasNextPage" & vbLf & "	endCursor" & vbLf & "}")
success = json.UpdateString("variables","{" & vbLf & "	""advertPageSize"": 50," & vbLf & "	""advertEndCursor"": null," & vbLf & "	""variantPageSize"": 5," & vbLf & "	""variantEndCursor"": null," & vbLf & "	""sellerIds"": [" & vbLf & "		""U2VsbGVyLTY2MDExOQ==""," & vbLf & "		""U2VsbGVyLTcw\vbLf & "	]" & vbLf & "}")

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

Dim resp As ChilkatHttpResponse
Set resp = http.PostJson3("https://bestfriendbazaar.com/graphql","application/json",json)
If (http.LastMethodSuccess = 0) Then
    Debug.Print http.LastErrorText
    Exit Sub
End If

Debug.Print resp.StatusCode
Debug.Print resp.BodyStr

Curl Command

curl -X POST
	-u '{{username}}:{{password}}'
	-H "MARKETPLACER-API-KEY: {{api_key}}"
	-H "Content-Type: application/json"
	--data-raw '{"query":"query ProductSearchBySellerId(\n\t$sellerIds: [ID!]\n\t$advertPageSize: Int\n\t$advertEndCursor: String\n\t$variantPageSize: Int\n\t$variantEndCursor: String\n) {\n\tadvertSearch(attributes: { sellerIds: $sellerIds }) {\n\t\tadverts(first: $advertPageSize, after: $advertEndCursor) {\n\t\t\ttotalCount\n\t\t\tpageInfo {\n\t\t\t\t...PageInfoPartial\n\t\t\t}\n\t\t\tedges {\n\t\t\t\tnode {\n\t\t\t\t\tid\n\t\t\t\t\tpriceUnit\n\t\t\t\t\ttitle\n\t\t\t\t\tseller {\n\t\t\t\t\t\tbusinessName\n\t\t\t\t\t}\n\n\t\t\t\t\tvariants(first: $variantPageSize, after: $variantEndCursor) {\n\t\t\t\t\t\ttotalCount\n\t\t\t\t\t\tpageInfo {\n\t\t\t\t\t\t\t...PageInfoPartial\n\t\t\t\t\t\t}\n\t\t\t\t\t\tedges {\n\t\t\t\t\t\t\tnode {\n\t\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\t\tlowestPrice\n\t\t\t\t\t\t\t\tcountOnHand\n\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfragment PageInfoPartial on PageInfo {\n\thasNextPage\n\tendCursor\n}","variables":"{\n\t\"advertPageSize\": 50,\n\t\"advertEndCursor\": null,\n\t\"variantPageSize\": 5,\n\t\"variantEndCursor\": null,\n\t\"sellerIds\": [\n\t\t\"U2VsbGVyLTY2MDExOQ==\",\n\t\t\"U2VsbGVyLTcw\"\n\t]\n}"}'
https://bestfriendbazaar.com/graphql

Postman Collection Item JSON

{
  "name": "advertSearch (Search by Seller Ids)",
  "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 ProductSearchBySellerId(\n\t$sellerIds: [ID!]\n\t$advertPageSize: Int\n\t$advertEndCursor: String\n\t$variantPageSize: Int\n\t$variantEndCursor: String\n) {\n\tadvertSearch(attributes: { sellerIds: $sellerIds }) {\n\t\tadverts(first: $advertPageSize, after: $advertEndCursor) {\n\t\t\ttotalCount\n\t\t\tpageInfo {\n\t\t\t\t...PageInfoPartial\n\t\t\t}\n\t\t\tedges {\n\t\t\t\tnode {\n\t\t\t\t\tid\n\t\t\t\t\tpriceUnit\n\t\t\t\t\ttitle\n\t\t\t\t\tseller {\n\t\t\t\t\t\tbusinessName\n\t\t\t\t\t}\n\n\t\t\t\t\tvariants(first: $variantPageSize, after: $variantEndCursor) {\n\t\t\t\t\t\ttotalCount\n\t\t\t\t\t\tpageInfo {\n\t\t\t\t\t\t\t...PageInfoPartial\n\t\t\t\t\t\t}\n\t\t\t\t\t\tedges {\n\t\t\t\t\t\t\tnode {\n\t\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\t\tlowestPrice\n\t\t\t\t\t\t\t\tcountOnHand\n\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfragment PageInfoPartial on PageInfo {\n\thasNextPage\n\tendCursor\n}",
        "variables": "{\n\t\"advertPageSize\": 50,\n\t\"advertEndCursor\": null,\n\t\"variantPageSize\": 5,\n\t\"variantEndCursor\": null,\n\t\"sellerIds\": [\n\t\t\"U2VsbGVyLTY2MDExOQ==\",\n\t\t\"U2VsbGVyLTcw\"\n\t]\n}"
      }
    },
    "url": {
      "raw": "{{base_url}}",
      "host": [
        "{{base_url}}"
      ],
      "path": null
    },
    "description": null
  },
  "response": [
  ]
}