I’m trying to implement a custom app into Make and am running into a problem. The problem is that this specific API requires that all requests be signed with an SHA256 signature encoded using the request’s body. The signature itself is just passed as a header: "X-BAPI-SIGN": "<encoded signature>"
.
The API documentation states that the string that should be used to generate this signature should be the timestamp + API key + (recv_window) + (jsonBodyString). The first 3 parts are easy and I implemented them into my custom app using the following code:
"X-BAPI-SIGN": "{{sha256(toString(timestamp) + toString(connection.apiKey) + toString(parameters.recv_window), 'hex', connection.privateKey)}}"
The issue is with the last bit: (jsonBodyString) - you’re supposed to convert the entire body object into a string (usually using a JSON.stringify function or something similar) and then escape the double quotations using a backslash. So, a body object that looks like this
{
"qty": "1",
"side": "Buy",
"price": "1000",
"symbol": "ETHUSDT",
"category": "linear",
"orderType": "Limit",
"isLeverage": 0,
"timeInForce": "GTC"
}
is supposed to be converted to a JSON string that looks like this:
{\"qty\":\"1\",\"side\":\"Buy\",\"price\":\"1000\",\"symbol\":\"ETHUSDT\",\"category\":\"linear\",\"orderType\":\"Limit\",\"isLeverage\":0,\"timeInForce\":\"GTC\"}
I just cannot figure out any way to do this without having to resort to custom functions in Make. I’ve tried: {{toString(parameters)}}
, {{toString(body)}}
, {{join(toArray(body), ',')}}
, and a bunch of other random things trying to get this to work. I don’t know if this is something that is even possible - any help or a point in the right direction would be greatly appreciated.