Chilkat Online Tools

Android / LHDN MyInvois SDK / Search Documents

Back to Collection Items

// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // 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("submissionDateFrom","{submissionDateFrom}");
    queryParams.UpdateString("submissionDateTo","{submissionDateTo}");
    queryParams.UpdateString("continuationToken","{continuationToken}");
    queryParams.UpdateString("pageSize","{pageSize}");
    queryParams.UpdateString("issueDateFrom","{issueDateFrom}");
    queryParams.UpdateString("issueDateTo","{issueDateTo}");
    queryParams.UpdateString("direction","{direction}");
    queryParams.UpdateString("status","{status}");
    queryParams.UpdateString("documentType","{documentType}");
    queryParams.UpdateString("receiverId","{receiverId}");
    queryParams.UpdateString("receiverIdType","{receiverIdType}");
    queryParams.UpdateString("issuerTin","{issuerTin}");
    queryParams.UpdateString("receiverTin","{receiverTin}");

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

    CkHttpResponse resp = http.QuickRequestParams("GET","https://{apiBaseUrl}/api/v1.0/documents/search",queryParams);
    if (http.get_LastMethodSuccess() == false) {
        Log.i(TAG, http.lastErrorText());
        return;
        }

    Log.i(TAG, String.valueOf(resp.get_StatusCode()));
    Log.i(TAG, resp.bodyStr());


  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}

Curl Command

curl -G -d "submissionDateFrom=%7BsubmissionDateFrom%7D"
	-d "submissionDateTo=%7BsubmissionDateTo%7D"
	-d "continuationToken=%7BcontinuationToken%7D"
	-d "pageSize=%7BpageSize%7D"
	-d "issueDateFrom=%7BissueDateFrom%7D"
	-d "issueDateTo=%7BissueDateTo%7D"
	-d "direction=%7Bdirection%7D"
	-d "status=%7Bstatus%7D"
	-d "documentType=%7BdocumentType%7D"
	-d "receiverId=%7BreceiverId%7D"
	-d "receiverIdType=%7BreceiverIdType%7D"
	-d "issuerTin=%7BissuerTin%7D"
	-d "receiverTin=%7BreceiverTin%7D"
	-H "Authorization: Bearer <access_token>"
https://{apiBaseUrl}/api/v1.0/documents/search

Postman Collection Item JSON

{
  "name": "Search Documents",
  "request": {
    "auth": {
      "type": "bearer",
      "bearer": [
        {
          "key": "token",
          "value": "{generatedAccessToken}",
          "type": "string"
        }
      ]
    },
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{apiBaseUrl}/api/v1.0/documents/search?submissionDateFrom={submissionDateFrom}&submissionDateTo={submissionDateTo}&continuationToken={continuationToken}&pageSize={pageSize}&issueDateFrom={issueDateFrom}&issueDateTo={issueDateTo}&direction={direction}&status={status}&documentType={documentType}&receiverId={receiverId}&receiverIdType={receiverIdType}&issuerTin={issuerTin}&receiverTin={receiverTin}",
      "host": [
        "{apiBaseUrl}"
      ],
      "path": [
        "api",
        "v1.0",
        "documents",
        "search"
      ],
      "query": [
        {
          "key": null,
          "value": "",
          "disabled": true
        },
        {
          "key": "submissionDateFrom",
          "value": "{submissionDateFrom}",
          "description": "Optional: The start date and time when the document was submitted to the eInvoicing API, Time to be supplied in UTC timezone. Mandatory when ‘submissionDateTo’ is provided or issueDate filters are not used"
        },
        {
          "key": "submissionDateTo",
          "value": "{submissionDateTo}",
          "description": "Optional: The end date and time when the document was submitted to the eInvoicing API, Time to be supplied in UTC timezone. Mandatory when ‘submissionDateFrom’ is provided or issueDate filters are not used\n"
        },
        {
          "key": "continuationToken",
          "value": "{continuationToken}",
          "description": "Optional: Token provided to navigate to the next page. Must be omitted or use an empty string when requesting the first page.\n"
        },
        {
          "key": "pageSize",
          "value": "{pageSize}",
          "description": "Optional: number of the documents to retrieve per page. Page size cannot exceed system configured maximum page size for this API. Default is 100\n"
        },
        {
          "key": "issueDateFrom",
          "value": "{issueDateFrom}",
          "description": "Optional: The start date and time when the document was issued. Mandatory when ‘issueDateTo’ is provided or submissionDate filters are not used\n"
        },
        {
          "key": "issueDateTo",
          "value": "{issueDateTo}",
          "description": "Optional: The end date and time when the document was issued. Mandatory when ‘issueDateFrom’ is provided or submissionDate filters are not used\n"
        },
        {
          "key": "direction",
          "value": "{direction}",
          "description": "Optional: direction of the document. Possible values: (‘Sent’, ‘Received’). When not provided sent and received documents are retrieved.\n"
        },
        {
          "key": "status",
          "value": "{status}",
          "description": "Optional: status of the document. Possible values: (‘Valid’, ‘Invalid’, ‘Cancelled’, ‘Submitted’)\n"
        },
        {
          "key": "documentType",
          "value": "{documentType}",
          "description": "Optional: Unique name of the document type.\n"
        },
        {
          "key": "receiverId",
          "value": "{receiverId}",
          "description": "Optional: Document recipient identifier. Only can be used when ‘Direction’ filter is set to Sent. Possible values: (Business registration number, Passport Number, National ID)\n"
        },
        {
          "key": "receiverIdType",
          "value": "{receiverIdType}",
          "description": "Optional: Document recipient identifier type. Only can be used when ‘Direction’ filter is set to Sent. Possible values: (BRN, PASSPORT, NRIC, ARMY) This is mandatory in case the receiverId is provided\n"
        },
        {
          "key": "issuerTin",
          "value": "{issuerTin}",
          "description": "Optional: Document issuer identifier. Only can be used when ‘Direction’ filter is set to Received."
        },
        {
          "key": "receiverTin",
          "value": "{receiverTin}",
          "description": "Optional: Document receiver identifier. Only can be used when ‘Direction’ filter is set to Received."
        }
      ]
    }
  },
  "response": [
  ]
}