Getting "Signature for this request is not valid" Error When Making API Call with Nested Parameters

I am working with an API (not specifying which for privacy reasons(https://api.binance.com/sapi/v1/lending/auto-invest/plan/edit) that requires a signature for each request. The request includes several parameters, some of which are nested. Despite following the documentation closely and ensuring my parameters are correctly ordered and encoded, I keep receiving a “Signature for this request is not valid” error.

Request Format:

I’m sending a POST request with the following parameters encoded in the URL query string:

planId=7556415&subscriptionAmount=10&subscriptionCycle=DAILY&subscriptionStartTime=14&sourceAsset=USDT&details%5B0%5D.targetAsset=BTC&details%5B0%5D.percentage=40&details%5B1%5D.targetAsset=ETH&details%5B1%5D.percentage=40&timestamp=1711499028711&signature=046fe7821dd48e81407d6a56abb6484d09c50d7a4dec10d9282ad99952594025

Problem:

Despite these steps, the server responds with a “Signature for this request is not valid” error. It seems like my signature generation is correct for simpler parameters, but something might be off with the nested details parameters.

What I’ve Tried:

  • Double-checking the API secret and ensuring it’s correctly used.
  • Ensuring my computer’s clock is synchronized to avoid timestamp issues.
  • Manually encoding the nested parameters.

Question:

Has anyone encountered a similar issue, particularly with APIs that require nested parameters in the signature generation? How did you structure and encode such parameters successfully?

I’m looking for any insights or suggestions on how to correctly generate a signature that includes nested parameters or any common pitfalls that might lead to this error.

Thank you in advance for your help!