Open zonbloginc opened 11 months ago
After spending a short time to figure out, it seems the error message would be:
{"code":700002,"msg":"Signature for this request is not valid.","_method":"POST","_url":"https:\/\/api.mexc.com\/api\/v3\/capital\/withdraw\/apply","_httpcode":400} {"userId":"tony","exception":"[object] (Lin\Mxc\Exceptions\Exception(code: 0): {\"code\":700002,\"msg\":\"Signature for this request is not valid.\",\"_method\":\"POST\",\"_url\":\"https:\/\/api.mexc.com\/api\/v3\/capital\/withdraw\/apply\",\"_httpcode\":400}
Somehow, if use special characters in query URL, it didn't work and led to this 'signature' error.
Worked version: coin=USDT&network=EOS&address=XXX&amount=100&withdrawOrderId=TEST×tamp=1701231754000
Didn't work: coin=USDT&network=EOS%28TEST%29&address=XXX&amount=100&withdrawOrderId=TEST×tamp=1701231859000
I tried to build query URL manually but didn't work too: coin=USDT&network=EOS(TEST)&address=XXX&amount=100&withdrawOrderId=TEST×tamp=1701231754000
To clarify that your repo didn't have withdraw() function, I created a new one in SpotV3\Privates:
// POST /api/v3/capital/withdraw/apply // public function withdraw(array $data=[]){ $this->type='POST'; $this->path='/api/v3/capital/withdraw/apply'; $this->data=$data; return $this->exec(); }
After spending a short time to figure out, it seems the error message would be:
{"code":700002,"msg":"Signature for this request is not valid.","_method":"POST","_url":"https://api.mexc.com/api/v3/capital/withdraw/apply","_httpcode":400} {"userId":"tony","exception":"[object] (Lin\Mxc\Exceptions\Exception(code: 0): {"code":700002,"msg":"Signature for this request is not valid.","_method":"POST","_url":"https:\/\/api.mexc.com\/api\/v3\/capital\/withdraw\/apply","_httpcode":400}
Somehow, if use special characters in query URL, it didn't work and led to this 'signature' error.
Worked version: coin=USDT&network=EOS&address=XXX&amount=100&withdrawOrderId=TEST×tamp=1701231754000
Didn't work: coin=USDT&network=EOS%28TEST%29&address=XXX&amount=100&withdrawOrderId=TEST×tamp=1701231859000
I tried to build query URL manually but didn't work too: coin=USDT&network=EOS(TEST)&address=XXX&amount=100&withdrawOrderId=TEST×tamp=1701231754000
To clarify that your repo didn't have withdraw() function, I created a new one in SpotV3\Privates:
// POST /api/v3/capital/withdraw/apply // public function withdraw(array $data=[]){ $this->type='POST'; $this->path='/api/v3/capital/withdraw/apply'; $this->data=$data; return $this->exec(); }
Signature issues, special characters, may all require no encoding, I tried to solve this problem.
After spending a short time to figure out, it seems the error message would be:
{"code":700002,"msg":"Signature for this request is not valid.","_method":"POST","_url":"https://api.mexc.com/api/v3/capital/withdraw/apply","_httpcode":400} {"userId":"tony","exception":"[object] (Lin\Mxc\Exceptions\Exception(code: 0): {"code":700002,"msg":"Signature for this request is not valid.","_method":"POST","_url":"https:\/\/api.mexc.com\/api\/v3\/capital\/withdraw\/apply","_httpcode":400}
Somehow, if use special characters in query URL, it didn't work and led to this 'signature' error.
Worked version: coin=USDT&network=EOS&address=XXX&amount=100&withdrawOrderId=TEST×tamp=1701231754000
Didn't work: coin=USDT&network=EOS%28TEST%29&address=XXX&amount=100&withdrawOrderId=TEST×tamp=1701231859000
I tried to build query URL manually but didn't work too: coin=USDT&network=EOS(TEST)&address=XXX&amount=100&withdrawOrderId=TEST×tamp=1701231754000
To clarify that your repo didn't have withdraw() function, I created a new one in SpotV3\Privates:
// POST /api/v3/capital/withdraw/apply // public function withdraw(array $data=[]){ $this->type='POST'; $this->path='/api/v3/capital/withdraw/apply'; $this->data=$data; return $this->exec(); }
The post submission data is in the form_params way, and the special characters in it are not encoded, why is your submission data a GET URL splicing?
I discussed to one of MEXC supporter on this issue and he said:
The post submission data is in the form_params way, and the special characters in it are not encoded, why is your submission data a GET URL splicing?
This is the log version of http_build_query($this->data) in signature() function, not the POST URL.
coin=USDT&network=EOS&address=XXX&amount=100&withdrawOrderId=TEST×tamp=1701231754000
I still can't pass this annoying issue, maybe the error came from their API server?
I discussed to one of MEXC supporter on this issue and he said:
- the URL data: http_build_query($this->data) need to be encoded, so use http_build_query is satisfy the requirement.
- the POST URL doesn't need encode
The post submission data is in the form_params way, and the special characters in it are not encoded, why is your submission data a GET URL splicing?
This is the log version of http_build_query($this->data) in signature() function, not the POST URL.
coin=USDT&network=EOS&address=XXX&amount=100&withdrawOrderId=TEST×tamp=1701231754000
I still can't pass this annoying issue, maybe the error came from their API server?
I found a way you can try
echo $url=urldecode(http_build_query($arr));
Actually, I tried to build the query string for signature manually with/without encode and it still didn't work. MEXC also has recently changed the list of withdrawal networks into special character mode. Right now, most of networks have special characters in them, except several ones, such as EOS, OKT ...
So withdraw asset through API seems not possible at this moment.
I perform a withdrawal with MxcSpotV3 ->privates()->withdraw($data) and everything work fine except if I try to do anything with $data = ['network' => 'BEP20(BSC)'] or any network that contains special characters, like SPACE, or ' - '.
It made the query URL to be differ than expected:
API server expected: /api/v3/capital/withdraw/apply?coin=USDT&address=zzqqqqqqqqqq&amount=10&network=BEP20(BSC)&memo=MX10086×tamp={{timestamp}}&signature={{signature}}
The real one with the mxc repo: /api/v3/capital/withdraw/apply?coin=USDT&address=zzqqqqqqqqqq&amount=10&network=BEP20%28BSC%29&memo=MX10086×tamp={{timestamp}}&signature={{signature}}
It seems it can't convert these characters correct when pushing to the API servers. If I use the 'network' with simple type, such as ERC20, OP, MATIC, then there is no issue at all.
Can you take a look at this?