Author

Topic: Poloniex Api "invalid command" (Read 1431 times)

full member
Activity: 224
Merit: 100
September 29, 2016, 04:38:59 AM
#2
I think the correct def would be

def getOpenOrders(self,url,comand, market):

    nonce = int(time.time())
    print(comand)
    urlrequest = url  + '?apikey=' + self.apiKey +'&command='+comand + '&nonce=' +str(nonce) + '¤cyPair=' + str(market)
    print(urlrequest)
    param =  'command='+comand + 'nonce=' +str(nonce) +str(market)
    param =  'command='+comand + '&nonce=' +str(nonce) + "¤cyPair=" +str(market)

    signature =  hmac.new(self.Secret.encode(),param.encode(), hashlib.sha512).hexdigest()
    headers = {
            'Sign':signature,
            'Key': self.apiKey
        }

    self.r = requests.post(urlrequest,headers= headers,)
    print(self.r)
    print(self.r.json())

You must remove the striked line and add the line below mentioned above.

WHY?

Simple! It seems that you have not formatted the post data correctly in your param variable.

Hope this helps!
If not, just pm me Wink
newbie
Activity: 8
Merit: 0
September 28, 2016, 08:11:47 PM
#1
Hello i am developing a bot in python using the polonix api
I am trying to make request to private api the server reply my this error message: {'error': 'Invalid command.'}

this is my code someone coudl help me to fix it? is all the day that i try but It still dosent works!!!
def getOpenOrders(self,url,comand, market):

    nonce = int(time.time())
    print(comand)
    urlrequest = url  + '?apikey=' + self.apiKey +'&command='+comand + '&nonce=' +str(nonce) + '&market=' + str(market)
    print(urlrequest)
    param =  'command='+comand + 'nonce=' +str(nonce) +str(market)

    signature =  hmac.new(self.Secret.encode(),param.encode(), hashlib.sha512).hexdigest()
    headers = {
            'Sign':signature,
            'Key': self.apiKey
        }

    self.r = requests.post(urlrequest,headers= headers,)
    print(self.r)
    print(self.r.json())




I think there is problem with the signature but i dont know where.

ps this is the official documentation https://temp.poloniex.com/support/api/
Jump to: