Chilkat Online Tools

Powershell / Marketplacer SELLER API / Get Invoices with Filtering and Ordering

Back to Collection Items

Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"

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

$http = New-Object Chilkat.Http

$http.BasicAuth = $true
$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 GetInvoicesWithFilteringAndOrdering \n(\n\t$pageSize: Int\n\t$endCursor: String\n\t$sort: InvoiceSort\n\t$filters: InvoiceFilters\n){\n\tinvoices(\n\t\tfirst: $pageSize\n\t\tafter: $endCursor\n\t\tfilters: $filters\n\t\tsort: $sort\n\t) {\n\t\ttotalCount\n\t\tpageInfo {\n\t\t\t...PageInfoPartial\n\t\t}\n\t\tedges {\n\t\t\tnode {\n\t\t\t\tid\n\t\t\t\tlegacyId\n\t\t\t\tcreatedAt\n\t\t\t\tupdatedAt\n\t\t\t\torder {\n\t\t\t\t\tupdatedAt\n\t\t\t\t\tid\n\t\t\t\t}\n\t\t\t\tstatusFlags\n\t\t\t\tlineItems {\n\t\t\t\t\tid\n\t\t\t\t\tvariantId\n\t\t\t\t\tvariantSku\n\t\t\t\t\tvariantBarcode\n\t\t\t\t\tvariantName\n\t\t\t\t\ttotalCents\n\t\t\t\t}\n\t\t\t\tshipments {\n\t\t\t\t\tid\n\t\t\t\t\tdispatchedAt\n\t\t\t\t\tshippedItems {\n\t\t\t\t\t\tid\n\t\t\t\t\t\tlineItem {\n\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\tadvertTitle\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}\n",
#   "variables": "{\n\t\"pageSize\": 100,\n\t\"endCursor\": \"\",\n\t\"sort\": {\n\t\t\"fields\": [\n\t\t\t\"UPDATED_AT\"\n\t\t],\n\t\t\"ordering\": \"DESCENDING\"\n\t},\n\t\"filters\": {\n\t\t\"updatedSince\": \"2022-01-01\"\n\t}\n}"
# }

$json = New-Object Chilkat.JsonObject
$json.UpdateString("query","query GetInvoicesWithFilteringAndOrdering `n(`n	$pageSize: Int`n	$endCursor: String`n	$sort: InvoiceSort`n	$filters: InvoiceFilters`n){`n	invoices(`n		first: $pageSize`n		after: $endCursor`n		filters: $filters`n		sort: $sort`n	) {`n		totalCount`n		pageInfo {`n			...PageInfoPartial`n		}`n		edges {`n			node {`n				id`n				legacyId`n				createdAt`n				updatedAt`n				order {`n					updatedAt`n					id`n				}`n				statusFlags`n				lineItems {`n					id`n					variantId`n					variantSku`n					variantBarcode`n					variantName`n					totalCents`n				}`n				shipments {`n					id`n					dispatchedAt`n					shippedItems {`n						id`n						lineItem {`n							id`n							advertTitle`n						}`n					}`n				}`n			}`n		}`n	}`n}`n`nfragment PageInfoPartial on PageInfo {`n	hasNextPage`n	endCursor`n}`n")
$json.UpdateString("variables","{`n	`"pageSize`": 100,`n	`"endCursor`": `"`",`n	`"sort`": {`n		`"fields`": [`n			`"UPDATED_AT`"`n		],`n		`"ordering`": `"DESCENDING`"`n	},`n	`"filters`": {`n		`"updatedSince`": `"2022-01-01`"`n	}`n}")

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

$resp = $http.PostJson3("https://bestfriendbazaar.com/graphql","application/json",$json)
if ($http.LastMethodSuccess -eq $false) {
    $($http.LastErrorText)
    exit
}

$($resp.StatusCode)
$($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 GetInvoicesWithFilteringAndOrdering \n(\n\t$pageSize: Int\n\t$endCursor: String\n\t$sort: InvoiceSort\n\t$filters: InvoiceFilters\n){\n\tinvoices(\n\t\tfirst: $pageSize\n\t\tafter: $endCursor\n\t\tfilters: $filters\n\t\tsort: $sort\n\t) {\n\t\ttotalCount\n\t\tpageInfo {\n\t\t\t...PageInfoPartial\n\t\t}\n\t\tedges {\n\t\t\tnode {\n\t\t\t\tid\n\t\t\t\tlegacyId\n\t\t\t\tcreatedAt\n\t\t\t\tupdatedAt\n\t\t\t\torder {\n\t\t\t\t\tupdatedAt\n\t\t\t\t\tid\n\t\t\t\t}\n\t\t\t\tstatusFlags\n\t\t\t\tlineItems {\n\t\t\t\t\tid\n\t\t\t\t\tvariantId\n\t\t\t\t\tvariantSku\n\t\t\t\t\tvariantBarcode\n\t\t\t\t\tvariantName\n\t\t\t\t\ttotalCents\n\t\t\t\t}\n\t\t\t\tshipments {\n\t\t\t\t\tid\n\t\t\t\t\tdispatchedAt\n\t\t\t\t\tshippedItems {\n\t\t\t\t\t\tid\n\t\t\t\t\t\tlineItem {\n\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\tadvertTitle\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}\n","variables":"{\n\t\"pageSize\": 100,\n\t\"endCursor\": \"\",\n\t\"sort\": {\n\t\t\"fields\": [\n\t\t\t\"UPDATED_AT\"\n\t\t],\n\t\t\"ordering\": \"DESCENDING\"\n\t},\n\t\"filters\": {\n\t\t\"updatedSince\": \"2022-01-01\"\n\t}\n}"}'
https://bestfriendbazaar.com/graphql

Postman Collection Item JSON

{
  "name": "Get Invoices with Filtering and Ordering",
  "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 GetInvoicesWithFilteringAndOrdering \n(\n\t$pageSize: Int\n\t$endCursor: String\n\t$sort: InvoiceSort\n\t$filters: InvoiceFilters\n){\n\tinvoices(\n\t\tfirst: $pageSize\n\t\tafter: $endCursor\n\t\tfilters: $filters\n\t\tsort: $sort\n\t) {\n\t\ttotalCount\n\t\tpageInfo {\n\t\t\t...PageInfoPartial\n\t\t}\n\t\tedges {\n\t\t\tnode {\n\t\t\t\tid\n\t\t\t\tlegacyId\n\t\t\t\tcreatedAt\n\t\t\t\tupdatedAt\n\t\t\t\torder {\n\t\t\t\t\tupdatedAt\n\t\t\t\t\tid\n\t\t\t\t}\n\t\t\t\tstatusFlags\n\t\t\t\tlineItems {\n\t\t\t\t\tid\n\t\t\t\t\tvariantId\n\t\t\t\t\tvariantSku\n\t\t\t\t\tvariantBarcode\n\t\t\t\t\tvariantName\n\t\t\t\t\ttotalCents\n\t\t\t\t}\n\t\t\t\tshipments {\n\t\t\t\t\tid\n\t\t\t\t\tdispatchedAt\n\t\t\t\t\tshippedItems {\n\t\t\t\t\t\tid\n\t\t\t\t\t\tlineItem {\n\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\tadvertTitle\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}\n",
        "variables": "{\n\t\"pageSize\": 100,\n\t\"endCursor\": \"\",\n\t\"sort\": {\n\t\t\"fields\": [\n\t\t\t\"UPDATED_AT\"\n\t\t],\n\t\t\"ordering\": \"DESCENDING\"\n\t},\n\t\"filters\": {\n\t\t\"updatedSince\": \"2022-01-01\"\n\t}\n}"
      }
    },
    "url": {
      "raw": "{{base_url}}",
      "host": [
        "{{base_url}}"
      ],
      "path": null
    },
    "description": null
  },
  "response": [
  ]
}