Chilkat Online Tools

PureBasic / Coupa Postman Collection - OAuth - Master / Get Unbacked Charges - Not Exported

Back to Collection Items

IncludeFile "CkJsonObject.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"

Procedure ChilkatExample()

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

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success.i

    queryParams.i = CkJsonObject::ckCreate()
    If queryParams.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckUpdateString(queryParams,"exported","false")
    CkJsonObject::ckUpdateString(queryParams,"virtual_card[document_type][blank]","true")
    CkJsonObject::ckUpdateString(queryParams,"fields","[" + Chr(34) + "id" + Chr(34) + "," + Chr(34) + "external_ref_id" + Chr(34) + "," + Chr(34) + "virtual_card_id" + Chr(34) + "," + Chr(34) + "coupa_pay_id" + Chr(34) + "," + Chr(34) + "coupa_pay_statement_id" + Chr(34) + "," + Chr(34) + "statement_id" + Chr(34) + "," + Chr(34) + "supplier_id" + Chr(34) + "," + Chr(34) + "charge_date" + Chr(34) + "," + Chr(34) + "total" + Chr(34) + "," + Chr(34) + "merchant_total" + Chr(34) + "," + Chr(34) + "merchant_reference" + Chr(34) + "," + Chr(34) + "card_provider_account" + Chr(34) + "," + Chr(34) + "exported" + Chr(34) + "," + Chr(34) + "tax_total" + Chr(34) + "," + Chr(34) + "accounting_total" + Chr(34) + "," + Chr(34) + "supplier_name" + Chr(34) + "," + Chr(34) + "account_type_id" + Chr(34) + "," + Chr(34) + "order_header_id" + Chr(34) + "," + Chr(34) + "order_header_number" + Chr(34) + "," + Chr(34) + "document_type" + Chr(34) + ",{" + Chr(34) + "currency" + Chr(34) + ":[" + Chr(34) + "code" + Chr(34) + "]},{" + Chr(34) + "merchant_currency" + Chr(34) + ":[" + Chr(34) + "code" + Chr(34) + "]},{" + Chr(34) + "accounting_currency" + Chr(34) + ":[" + Chr(34) + "code" + Chr(34) + "]},{" + Chr(34) + "charge_allocations" + Chr(34) + ": [" + Chr(34) + "id" + Chr(34) + "," + Chr(34) + "amount" + Chr(34) + "," + Chr(34) + "pct" + Chr(34) + ",{" + Chr(34) + "account" + Chr(34) + ": [" + Chr(34) + "id" + Chr(34) + "," + Chr(34) + "name" + Chr(34) + "," + Chr(34) + "code" + Chr(34) + "," + Chr(34) + "segment_1" + Chr(34) + "," + Chr(34) + "segment_2" + Chr(34) + "," + Chr(34) + "segment_3" + Chr(34) + "," + Chr(34) + "segment_4" + Chr(34) + "," + Chr(34) + "segment_5" + Chr(34) + "," + Chr(34) + "segment_6" + Chr(34) + "," + Chr(34) + "segment_7" + Chr(34) + "," + Chr(34) + "segment_8" + Chr(34) + "]},{" + Chr(34) + "currency" + Chr(34) + ":[" + Chr(34) + "code" + Chr(34) + "]},{" + Chr(34) + "tax_lines" + Chr(34) + ": [" + Chr(34) + "amount" + Chr(34) + "," + Chr(34) + "rate" + Chr(34) + "," + Chr(34) + "code" + Chr(34) + "," + Chr(34) + "description" + Chr(34) + "," + Chr(34) + "taxable_amount" + Chr(34) + "]  }]}]")

    ; Adds the "Authorization: Bearer <access_token>" header.
    CkHttp::setCkAuthToken(http, "<access_token>")

    resp.i = CkHttp::ckQuickRequestParams(http,"GET","https://domain.com/charges",queryParams)
    If CkHttp::ckLastMethodSuccess(http) = 0
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        CkJsonObject::ckDispose(queryParams)
        ProcedureReturn
    EndIf

    Debug Str(CkHttpResponse::ckStatusCode(resp))
    Debug CkHttpResponse::ckBodyStr(resp)
    CkHttpResponse::ckDispose(resp)



    CkHttp::ckDispose(http)
    CkJsonObject::ckDispose(queryParams)


    ProcedureReturn
EndProcedure

Curl Command

curl -G -d "exported=false"
	-d "virtual_card[document_type][blank]=true"
	-d "fields=%5B%22id%22,%22external_ref_id%22,%22virtual_card_id%22,%22coupa_pay_id%22,%22coupa_pay_statement_id%22,%22statement_id%22,%22supplier_id%22,%22charge_date%22,%22total%22,%22merchant_total%22,%22merchant_reference%22,%22card_provider_account%22,%22exported%22,%22tax_total%22,%22accounting_total%22,%22supplier_name%22,%22account_type_id%22,%22order_header_id%22,%22order_header_number%22,%22document_type%22,%7B%22currency%22%3A%5B%22code%22%5D%7D,%7B%22merchant_currency%22%3A%5B%22code%22%5D%7D,%7B%22accounting_currency%22%3A%5B%22code%22%5D%7D,%7B%22charge_allocations%22%3A%20%5B%22id%22,%22amount%22,%22pct%22,%7B%22account%22%3A%20%5B%22id%22,%22name%22,%22code%22,%22segment_1%22,%22segment_2%22,%22segment_3%22,%22segment_4%22,%22segment_5%22,%22segment_6%22,%22segment_7%22,%22segment_8%22%5D%7D,%7B%22currency%22%3A%5B%22code%22%5D%7D,%7B%22tax_lines%22%3A%20%5B%22amount%22,%22rate%22,%22code%22,%22description%22,%22taxable_amount%22%5D%20%20%7D%5D%7D%5D"
	-H "Authorization: Bearer <access_token>"
https://domain.com/charges

Postman Collection Item JSON

{
  "name": "Get Unbacked Charges - Not Exported",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{URL}}/charges?exported=false&virtual_card[document_type][blank]=true&fields=[\"id\",\"external_ref_id\",\"virtual_card_id\",\"coupa_pay_id\",\"coupa_pay_statement_id\",\"statement_id\",\"supplier_id\",\"charge_date\",\"total\",\"merchant_total\",\"merchant_reference\",\"card_provider_account\",\"exported\",\"tax_total\",\"accounting_total\",\"supplier_name\",\"account_type_id\",\"order_header_id\",\"order_header_number\",\"document_type\",{\"currency\":[\"code\"]},{\"merchant_currency\":[\"code\"]},{\"accounting_currency\":[\"code\"]},{\"charge_allocations\": [\"id\",\"amount\",\"pct\",{\"account\": [\"id\",\"name\",\"code\",\"segment_1\",\"segment_2\",\"segment_3\",\"segment_4\",\"segment_5\",\"segment_6\",\"segment_7\",\"segment_8\"]},{\"currency\":[\"code\"]},{\"tax_lines\": [\"amount\",\"rate\",\"code\",\"description\",\"taxable_amount\"]  }]}]",
      "host": [
        "{{URL}}"
      ],
      "path": [
        "charges"
      ],
      "query": [
        {
          "key": "exported",
          "value": "false"
        },
        {
          "key": "virtual_card[document_type][blank]",
          "value": "true"
        },
        {
          "key": "fields",
          "value": "[\"id\",\"external_ref_id\",\"virtual_card_id\",\"coupa_pay_id\",\"coupa_pay_statement_id\",\"statement_id\",\"supplier_id\",\"charge_date\",\"total\",\"merchant_total\",\"merchant_reference\",\"card_provider_account\",\"exported\",\"tax_total\",\"accounting_total\",\"supplier_name\",\"account_type_id\",\"order_header_id\",\"order_header_number\",\"document_type\",{\"currency\":[\"code\"]},{\"merchant_currency\":[\"code\"]},{\"accounting_currency\":[\"code\"]},{\"charge_allocations\": [\"id\",\"amount\",\"pct\",{\"account\": [\"id\",\"name\",\"code\",\"segment_1\",\"segment_2\",\"segment_3\",\"segment_4\",\"segment_5\",\"segment_6\",\"segment_7\",\"segment_8\"]},{\"currency\":[\"code\"]},{\"tax_lines\": [\"amount\",\"rate\",\"code\",\"description\",\"taxable_amount\"]  }]}]"
        }
      ]
    }
  },
  "response": [
  ]
}