constdatetime=newDate().toISOString();// Set a "date" HTTP header using DATETIME as its value in the UI
dd.variable.set("DATETIME",datetime);constmessage="Hello, World!";// Use BODY as the request body in the UI
dd.variable.set("BODY",message);constsecretKeyUtf8=dd.variable.get("MY_SECRET_KEY");constkey=awaitcrypto.subtle.importKey("raw",newTextEncoder().encode(secretKeyUtf8),{name:"HMAC",hash:"SHA-256"},false,["sign"]);constrawSignature=awaitcrypto.subtle.sign({name:"HMAC"},key,newTextEncoder().encode(datetime+"."+message));// Set an "authentication" HTTP header using SIGNATURE as its value in the UI
dd.variable.set("SIGNATURE",std.encoding.hex.encodeHex(rawSignature));// Alternative:
dd.variable.set("SIGNATURE_BASE64",std.encoding.base64.encode(rawSignature));
リクエストヘッダーに HMAC 署名を追加する
エクスポートされた SIGNATURE 変数を使用して、HTTP リクエストヘッダーを構築します。
Request Options タブで、Name を Authentication に、Value を に設定したヘッダーを追加します。{{ SIGNATURE }}, and another one with Name を Date and Value を に設定します。{{ DATETIME }}. You can define a different header such as Authorization。