Hello! It’s my first time posting in a community like this… hopefully I’m doing this the right way! Please bear with me as my technical background is very weak.
[Goal]
From Make, I’m trying to call an API in Lazada.
For this, they require a “Signature” included in the request parameter, which uses some algorithm, UTF-8 encoding, and SHA256 hashing.
However, I can’t seem to get this right as I encounter an error that says “The request signature does not conform to platform standards.” I think I’m not able to follow the algorithm properly using Make, and would really appreciate your help.
[Lazada’s Signature algorithm]
So according to their documentation linked here, there are 5 steps to generating the signature.
Step 1: Sort all request parameters (including system and application parameters, but except the “sign” and parameters with byte array type) according to the parameter name in ASCII table. For example:
Before sort: foo=1, bar=2, foo_bar=3, foobar=4
After sort: bar=2, foo=1, foo_bar=3, foobar=4
Step2: Concatenate the sorted parameters and their values into a string. For example:
bar2foo1foo_bar3foobar4
Step3: Add the API name in front of the concatenated string. For example, adding the API name “/test/api”:
/test/apibar2foo1foo_bar3foobar4
Step4: Encode the concatenated string in UTF-8 format and make a digest by the signature algorithm (using HMAC_SHA256). For example:
hmac_sha256(/test/apibar2foo1foo_bar3foobar4)
Step5: 1. Convert the digest to hexadecimal format. For example:
hex(“helloworld”.getBytes(“utf-8”)) = “68656C6C6F776F726C64”
Steps 1 to 3 are straightforward. I’m trying to apply the resulting text into Steps4 and 5, which I think is the part I can’t figure out.
[Steps I tried]
I created the string and put it into the sha256 function like the below. (I’m also using the formatDate and parseDate function as a part of the signature because the signature requires a timestamp in the format of Unix Millisecond Timestamp. )
I’m not quite sure how to do Step 4, around encoding the string into UTF-8 format, and I’m guessing that may be my issue.
My error is the below.
Please help me on how to achieve this Signature!