Chilkat Online Tools

Java / Coupa Postman Collection - OAuth - Master / Query Approval records

Back to Collection Items

import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttp http = new CkHttp();
    boolean success;

    CkJsonObject queryParams = new CkJsonObject();
    queryParams.UpdateString("approvable-type","EasyFormResponse");
    queryParams.UpdateString("status[in]","pending_approval,approved");
    queryParams.UpdateString("approver-type","RemoteApprover");
    queryParams.UpdateInt("approver-id",1);
    queryParams.UpdateString("fields","[\"approvable_type\",\"approvable_id\"]");

    // Adds the "Authorization: Bearer <access_token>" header.
    http.put_AuthToken("<access_token>");

    CkHttpResponse resp = http.QuickRequestParams("GET","https://domain.com/approvals",queryParams);
    if (http.get_LastMethodSuccess() == false) {
        System.out.println(http.lastErrorText());
        return;
        }

    System.out.println(resp.get_StatusCode());
    System.out.println(resp.bodyStr());
  }
}

Curl Command

curl -G -d "approvable-type=EasyFormResponse"
	-d "status[in]=pending_approval,approved"
	-d "approver-type=RemoteApprover"
	-d "approver-id=1"
	-d "fields=%5B%22approvable_type%22,%22approvable_id%22%5D"
	-H "Authorization: Bearer <access_token>"
https://domain.com/approvals

Postman Collection Item JSON

{
  "name": "Query Approval records",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{URL}}/approvals?approvable-type=EasyFormResponse&status[in]=pending_approval,approved&approver-type=RemoteApprover&approver-id=1&fields=[\"approvable_type\",\"approvable_id\"]",
      "host": [
        "{{URL}}"
      ],
      "path": [
        "approvals"
      ],
      "query": [
        {
          "key": "approvable-type",
          "value": "EasyFormResponse"
        },
        {
          "key": "status[in]",
          "value": "pending_approval,approved"
        },
        {
          "key": "approver-type",
          "value": "RemoteApprover"
        },
        {
          "key": "approver-id",
          "value": "1"
        },
        {
          "key": "fields",
          "value": "[\"approvable_type\",\"approvable_id\"]"
        }
      ]
    }
  },
  "response": [
  ]
}