Calculating the Signature and DGRK

Original Request Body JSON

Example:

{
"ReqHeader": {
"txSN": "1220315140419qRRXvZ",
"txDate": "20220315T140419+0800",
"txID": "DPB0044",
"cID": "YWRtaW5Db25zb2xl",
"locale": "zh-TW"
},
"ReqBody": {
"keyword": "",
"queryStartDate": "2021/08/01",
"queryEndDate": "2022/03/15",
"typeItemNo": "",
"enFlagEncode": "JDJhJDA0JGpHRlc3dHl0WlRnbC5YbmV5SnFBdGVkaXhmY1Z1LlouVlIxRWprVy5SYkRDTmRabTd2M3oy,0",
"fbTypeEncode": "JDJhJDA0JFpWQjdYU1F5ckNsUjBOOWxic2tjamVnOFI4ck1xbU9sNy54SkZ0Z0VLWmthLkpmQmJFTWdL,1"
}
}

Minimizing Request Body JSON

Example:

{"ReqHeader":{"txSN":"1220315140419qRRXvZ","txDate":"20220315T140419+0800","txID":"DPB0044","cID":"YWRtaW5Db25zb2xl","locale":"zh-TW"},"ReqBody":{"keyword":"","queryStartDate":"2021/08/01","queryEndDate":"2022/03/15","typeItemNo":"","enFlagEncode":"JDJhJDA0JGpHRlc3dHl0WlRnbC5YbmV5SnFBdGVkaXhmY1Z1LlouVlIxRWprVy5SYkRDTmRabTd2M3oy,0","fbTypeEncode":"JDJhJDA0JFpWQjdYU1F5ckNsUjBOOWxic2tjamVnOFI4ck1xbU9sNy54SkZ0Z0VLWmthLkpmQmJFTWdL,1"}}

Adding API Key and Secret Key

Example:

{"ReqHeader":{"txSN":"1220315140419qRRXvZ","txDate":"20220315T140419+0800","txID":"DPB0044","cID":"YWRtaW5Db25zb2xl","locale":"zh-TW"},"ReqBody":{"keyword":"","queryStartDate":"2021/08/01","queryEndDate":"2022/03/15","typeItemNo":"","enFlagEncode":"JDJhJDA0JGpHRlc3dHl0WlRnbC5YbmV5SnFBdGVkaXhmY1Z1LlouVlIxRWprVy5SYkRDTmRabTd2M3oy,0","fbTypeEncode":"JDJhJDA0JFpWQjdYU1F5ckNsUjBOOWxic2tjamVnOFI4ck1xbU9sNy54SkZ0Z0VLWmthLkpmQmJFTWdL,1"}}YjQxNzJlMjFiMzAzM2Q5NWM2ZDYzNTVjYzhmMTRjNGQxMTA3YzllYw==YTk2MTQ2MjhhZDM1MjYwZDVkMTdjMTE2MTIyZDhkOTFhNmNiNGI3NjNmMjg1ZTgzMWI3OGQ1ZGZlNDA2OGNkYw==

Obtaining Digital Signature

Insert the Secret Key into the secretKey variable of the sample program. Incorporate the aforementioned data into the message variable, output it as a byte array, apply HMAC SHA256 encryption, and then use Base64 encoding to obtain the Signature (Digital Signature).

Example signature:

Q22n2yrakE60W8eGduraBPddPECSdJpLFPY7ojpnKr0=

Example program:

Obtaining DGRK

Combine the API Key with a period (.), and append the Signature to obtain the DGRK.

Example:

YjQxNzJlMjFiMzAzM2Q5NWM2ZDYzNTVjYzhmMTRjNGQxMTA3YzllYw==.Q22n2yrakE60W8eGduraBPddPECSdJpLFPY7ojpnKr0=

Was this helpful?