Chilkat Online Tools

SQL Server / LHDN MyInvois SDK / Get Notifications

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, 'dateFrom', '{dateFrom}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'dateTo', '{dateTo}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'type', '{type}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'language', '{language}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'status', '{status}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'channel', '{channel}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'pageNo', '{pageNo}'
    EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'pageSize', '{pageSize}'

    -- 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/notifications/taxpayer', @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 "dateFrom=%7BdateFrom%7D"
	-d "dateTo=%7BdateTo%7D"
	-d "type=%7Btype%7D"
	-d "language=%7Blanguage%7D"
	-d "status=%7Bstatus%7D"
	-d "channel=%7Bchannel%7D"
	-d "pageNo=%7BpageNo%7D"
	-d "pageSize=%7BpageSize%7D"
	-H "Authorization: Bearer <access_token>"
https://{apiBaseUrl}/api/v1.0/notifications/taxpayer

Postman Collection Item JSON

{
  "name": "Get Notifications",
  "request": {
    "auth": {
      "type": "bearer",
      "bearer": [
        {
          "key": "token",
          "value": "{generatedAccessToken}",
          "type": "string"
        }
      ]
    },
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{apiBaseUrl}/api/v1.0/notifications/taxpayer?dateFrom={dateFrom}&dateTo={dateTo}&type={type}&language={language}&status={status}&channel={channel}&pageNo={pageNo}&pageSize={pageSize}",
      "host": [
        "{apiBaseUrl}"
      ],
      "path": [
        "api",
        "v1.0",
        "notifications",
        "taxpayer"
      ],
      "query": [
        {
          "key": "dateFrom",
          "value": "{dateFrom}",
          "description": "Optional: start date and time for notifications to retrieve based on the date sent\n"
        },
        {
          "key": "dateTo",
          "value": "{dateTo}",
          "description": "Optional: end date and time for notifications to retrieve based on the date sent\n"
        },
        {
          "key": "type",
          "value": "{type}",
          "description": "Optional: type of notifications to retrieve specified as ID of the type. (Notification types to be discussed later)\n"
        },
        {
          "key": "language",
          "value": "{language}",
          "description": "Optional: used to get notifications only if they were sent out in a specific language. Values: ms and en\n"
        },
        {
          "key": "status",
          "value": "{status}",
          "description": "Optional: used to get notifications of certain status only, e.g., only those that were not delivered. Values: pending, batched, delivered, error\n"
        },
        {
          "key": "channel",
          "value": "{channel}",
          "description": "Optional: used to get notifications delivered over certain channel only. Values: email, push\n"
        },
        {
          "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 packages to retrieve per page. Page size cannot exceed system configured maximum page size for this API\n"
        }
      ]
    }
  },
  "response": [
  ]
}