SQL Server / LHDN MyInvois SDK / Get Recent Documents
Back to Collection Items
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
DECLARE @queryParams int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'pageNo', '{pageNo}'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'pageSize', '{pageSize}'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'submissionDateFrom', '{submissionDateFrom}'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'submissionDateTo', '{submissionDateTo}'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'issueDateFrom', '{issueDateFrom}'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'issueDateTo', '{IssueDateTo}'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'direction', '{direction}'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'status', '{status}'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'documentType', '{documentType}'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'receiverIdType', '{receiverIdType}'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'receiverId', '{receiverId}'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'receiverTin', '{receiverTin}'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'issuerTin', '{issuerTin}'
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://{apiBaseUrl}/api/v1.0/documents/recent', @queryParams
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
RETURN
END
EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
PRINT @iTmp0
EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
END
GO
Curl Command
curl -G -d "pageNo=%7BpageNo%7D"
-d "pageSize=%7BpageSize%7D"
-d "submissionDateFrom=%7BsubmissionDateFrom%7D"
-d "submissionDateTo=%7BsubmissionDateTo%7D"
-d "issueDateFrom=%7BissueDateFrom%7D"
-d "issueDateTo=%7BIssueDateTo%7D"
-d "direction=%7Bdirection%7D"
-d "status=%7Bstatus%7D"
-d "documentType=%7BdocumentType%7D"
-d "receiverIdType=%7BreceiverIdType%7D"
-d "receiverId=%7BreceiverId%7D"
-d "receiverTin=%7BreceiverTin%7D"
-d "issuerTin=%7BissuerTin%7D"
-H "Authorization: Bearer <access_token>"
https://{apiBaseUrl}/api/v1.0/documents/recent
Postman Collection Item JSON
{
"name": "Get Recent Documents",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{generatedAccessToken}",
"type": "string"
}
]
},
"method": "GET",
"header": [
],
"url": {
"raw": "{apiBaseUrl}/api/v1.0/documents/recent?pageNo={pageNo}&pageSize={pageSize}&submissionDateFrom={submissionDateFrom}&submissionDateTo={submissionDateTo}&issueDateFrom={issueDateFrom}&issueDateTo={IssueDateTo}&direction={direction}&status={status}&documentType={documentType}&receiverIdType={receiverIdType}&receiverId={receiverId}&receiverTin={receiverTin}&issuerTin={issuerTin}",
"host": [
"{apiBaseUrl}"
],
"path": [
"api",
"v1.0",
"documents",
"recent"
],
"query": [
{
"key": "pageNo",
"value": "{pageNo}",
"description": "Optional: number of the page to retrieve. Typically this parameter value is derived from initial parameter less call when caller learns total amount of page of certain size\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\n"
},
{
"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\n"
},
{
"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\n"
},
{
"key": "issueDateFrom",
"value": "{issueDateFrom}",
"description": "Optional: The start date and time when the document was issued. Mandatory when ‘issueDateTo’ is provided\n"
},
{
"key": "issueDateTo",
"value": "{IssueDateTo}",
"description": "Optional: The end date and time when the document was issued. Mandatory when ‘issueDateFrom’ is provided\n"
},
{
"key": "direction",
"value": "{direction}",
"description": "Optional: direction of the document. Possible values: (‘Sent’, ‘Received’)\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": "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": "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(NRIC), Army ID)\n"
},
{
"key": "receiverTin",
"value": "{receiverTin}",
"description": "Optional: Document recipient TIN. Only can be used when ‘Direction’ filter is set to Sent. \n"
},
{
"key": "issuerTin",
"value": "{issuerTin}",
"description": "Optional: Document issuer identifier. Only can be used when ‘Direction’ filter is set to Received.\n"
}
]
}
},
"response": [
]
}