Fehler 405 Beim Versuch, die Auszahlungsreihenfolge mit OKX API zu erstellenPython

Python-Programme
Anonymous
 Fehler 405 Beim Versuch, die Auszahlungsreihenfolge mit OKX API zu erstellen

Post by Anonymous »

I'm trying create a order of withdrawal, but the response alerts error 405. I read the docs and saw that this error is related of wrong method, but I'm sure that the correct is POST
The documentation is: https://www.okx.com/docs-v5/en/?typescr ... es-channel
The create-withdrawal-order: https://www.okx.com/docs-v5/en/?python# ... awal-order
Der Code, den ich verwende:
import json, requests
import base64, hmac
from datetime import datetime, timezone
import hashlib
import random
import string

class OkxAPI:
def __init__(self, APIKEY: str, APISECRET: str, PASS: str):
self.apikey = APIKEY
self.apisecret = APISECRET
self.password = PASS
self.baseURL = 'https://okx.com'

@staticmethod
def get_time():
timestamp = datetime.now(timezone.utc).isoformat(timespec='milliseconds').replace("+00:00", "Z")
return timestamp

@staticmethod
def create_client_id(length = 32):
characters = string.ascii_lowercase + string.digits
return ''.join(random.choices(characters, k=length))

def signature(self, timestamp, method, request_path, body, secret_key):
message = timestamp + method + request_path + body
signature = hmac.new(
self.apisecret.encode(), message.encode(), hashlib.sha256
).digest()
output = base64.b64encode(signature).decode()
return output

def get_header(self, request='GET', endpoint='', body=''):
cur_time = self.get_time()
header = dict()
header['CONTENT-TYPE'] = "application/json"
header['OK-ACCESS-KEY'] = self.apikey
header['OK-ACCESS-SIGN'] = self.signature(cur_time, request, endpoint, body, self.apisecret)
header['OK-ACCESS-TIMESTAMP'] = cur_time
header['OK-ACCESS-PASSPHRASE'] = self.password
return header

def withdrawal_payment_methods(self, ccy):
endpoint = f'/api/v5/fiat/withdrawal-payment-methods?ccy={ccy}'
url = self.baseURL + endpoint
# body = {
# 'ccy': ccy
# }
request = 'GET'
header = self.get_header(request, endpoint)
print(header)
response = requests.get(url, headers = header)
return response.json()

def create_withdrawal(self, ccy, amount):
clientId = self.create_client_id()
endpoint = f'/api/v5/fiat/create-withdrawal'
body = f"?paymentAcctId=my-account?ccy={ccy}?amt={amount}?paymentMethod=PIX?clientId={clientId}"
url = self.baseURL + endpoint
request = 'POST'
header = self.get_header(request, endpoint, body)
print(header)
response = requests.post(url, endpoint)
return response.json()

apiKey = ''
secretKey = ''
passphrase = ''
okx = OkxAPI(apiKey, secretKey, passphrase)
# print(okx.withdrawal_payment_methods('BRL'))
print(okx.create_withdrawal('BRL', '10'))
< /code>
Ich habe versucht, die Methode zu ändern, aber der Fehler bleibt bestehen. Ich implementiere auch eine andere Methode, Entzugung_Payment_Method, und es funktioniert, daher denke ich, dass Signatur/get_time in Ordnung ist.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post