Bitcoin Forum
June 28, 2024, 01:41:53 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Huobi API returns error: Invalid time format  (Read 187 times)
ilya1966 (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
June 05, 2018, 01:08:07 AM
 #1

Please, someone, help me to resolve my problem.
I try to retrieve my Huobi balances with API and always get error: "Signature not valid: Invalid time format".
Everything is done according to their help documents.

1) I create a signature using SHA256 generator with my secret key and text like this:

GET\n
api.huobi.pro\n
/v1/account/accounts/xxxxx.com/balance\n
AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2018-06-04T15%3A19%3A30

2) Enter this URL to my browser:

https://api.huobi.pro/v1/account/accounts/xxxxx.com/balance?AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx&order-id=1234567890&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2018-06-04T15%3A19%3A30&Signature=4F65x5jkbLyMWVQj3Aqp%2BB4w%2BivaAty5Oi2SuYtCJ9o%3D

The result is  {"status":"error","err-code":"api-signature-not-valid","err-msg":"Signature not valid: 无效的提交时间","data":null}

无效的提交时间 is  Invalid time format.

May be someone have experience with this stuff. Thank you in advance.
actuallytwolamas
Member
**
Offline Offline

Activity: 69
Merit: 20

Lama


View Profile WWW
June 05, 2018, 04:09:01 PM
 #2

I'm just making a blind guess, but I think you don't include Time zone in your Date format, you just passing current date without time zone, which they mentioned in documentation, that you need to include it.

There is js snippet to encode this string: encodeURIComponent("2018-05-04T12:10:36+UTC TIME ZONE"); or encodeURIComponent("2018-05-04T12:10:36+00:00"); which results in something like this 2018-05-04T12%3A10%3A36%2B00%3A00
ilya1966 (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
June 05, 2018, 05:30:42 PM
Last edit: June 05, 2018, 05:43:06 PM by ilya1966
 #3

I'm just making a blind guess, but I think you don't include Time zone in your Date format, you just passing current date without time zone, which they mentioned in documentation, that you need to include it.

There is js snippet to encode this string: encodeURIComponent("2018-05-04T12:10:36+UTC TIME ZONE"); or encodeURIComponent("2018-05-04T12:10:36+00:00"); which results in something like this 2018-05-04T12%3A10%3A36%2B00%3A00

Thank you. It's a good point. I tried to include my UTC zone (UTC-5) this ways:

2018-05-04T12%3A10%3A36%2B-5%3A00
and
2018-05-04T12%3A10%3A36%2B-5

and got another error - Incorrect Time Format.
But, maybe  2018-05-04T12%3A10%3A36%2B-05%3A00 will work. I'll try it.
Thanks.
actuallytwolamas
Member
**
Offline Offline

Activity: 69
Merit: 20

Lama


View Profile WWW
June 05, 2018, 06:51:13 PM
 #4

I'm just making a blind guess, but I think you don't include Time zone in your Date format, you just passing current date without time zone, which they mentioned in documentation, that you need to include it.

There is js snippet to encode this string: encodeURIComponent("2018-05-04T12:10:36+UTC TIME ZONE"); or encodeURIComponent("2018-05-04T12:10:36+00:00"); which results in something like this 2018-05-04T12%3A10%3A36%2B00%3A00

Thank you. It's a good point. I tried to include my UTC zone (UTC-5) this ways:

2018-05-04T12%3A10%3A36%2B-5%3A00
and
2018-05-04T12%3A10%3A36%2B-5

and got another error - Incorrect Time Format.
But, maybe  2018-05-04T12%3A10%3A36%2B-05%3A00 will work. I'll try it.
Thanks.
I think Time zone format has a strict rules it should always be +00:00, or -03:00, you must include all four numbers.
ilya1966 (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
June 05, 2018, 11:04:36 PM
 #5

I'm just making a blind guess, but I think you don't include Time zone in your Date format, you just passing current date without time zone, which they mentioned in documentation, that you need to include it.

There is js snippet to encode this string: encodeURIComponent("2018-05-04T12:10:36+UTC TIME ZONE"); or encodeURIComponent("2018-05-04T12:10:36+00:00"); which results in something like this 2018-05-04T12%3A10%3A36%2B00%3A00

Thank you. It's a good point. I tried to include my UTC zone (UTC-5) this ways:

2018-05-04T12%3A10%3A36%2B-5%3A00
and
2018-05-04T12%3A10%3A36%2B-5

and got another error - Incorrect Time Format.
But, maybe  2018-05-04T12%3A10%3A36%2B-05%3A00 will work. I'll try it.
Thanks.
I think Time zone format has a strict rules it should always be +00:00, or -03:00, you must include all four numbers.

I tried 2018-05-04T12%3A10%3A36%2B-05%3A00 but got  Incorrect Time Format. Maybe I get this error, because I have zero balances in Huobi. Sad
actuallytwolamas
Member
**
Offline Offline

Activity: 69
Merit: 20

Lama


View Profile WWW
June 06, 2018, 04:55:35 PM
 #6

I'm just making a blind guess, but I think you don't include Time zone in your Date format, you just passing current date without time zone, which they mentioned in documentation, that you need to include it.

There is js snippet to encode this string: encodeURIComponent("2018-05-04T12:10:36+UTC TIME ZONE"); or encodeURIComponent("2018-05-04T12:10:36+00:00"); which results in something like this 2018-05-04T12%3A10%3A36%2B00%3A00

Thank you. It's a good point. I tried to include my UTC zone (UTC-5) this ways:

2018-05-04T12%3A10%3A36%2B-5%3A00
and
2018-05-04T12%3A10%3A36%2B-5

and got another error - Incorrect Time Format.
But, maybe  2018-05-04T12%3A10%3A36%2B-05%3A00 will work. I'll try it.
Thanks.
I think Time zone format has a strict rules it should always be +00:00, or -03:00, you must include all four numbers.

I tried 2018-05-04T12%3A10%3A36%2B-05%3A00 but got  Incorrect Time Format. Maybe I get this error, because I have zero balances in Huobi. Sad
Wierd. Maybe you already find solution? because in google there is no answers at all.
ilya1966 (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
June 06, 2018, 05:49:23 PM
 #7

I'm just making a blind guess, but I think you don't include Time zone in your Date format, you just passing current date without time zone, which they mentioned in documentation, that you need to include it.

There is js snippet to encode this string: encodeURIComponent("2018-05-04T12:10:36+UTC TIME ZONE"); or encodeURIComponent("2018-05-04T12:10:36+00:00"); which results in something like this 2018-05-04T12%3A10%3A36%2B00%3A00

Thank you. It's a good point. I tried to include my UTC zone (UTC-5) this ways:

2018-05-04T12%3A10%3A36%2B-5%3A00
and
2018-05-04T12%3A10%3A36%2B-5

and got another error - Incorrect Time Format.
But, maybe  2018-05-04T12%3A10%3A36%2B-05%3A00 will work. I'll try it.
Thanks.
I think Time zone format has a strict rules it should always be +00:00, or -03:00, you must include all four numbers.

I tried 2018-05-04T12%3A10%3A36%2B-05%3A00 but got  Incorrect Time Format. Maybe I get this error, because I have zero balances in Huobi. Sad
Wierd. Maybe you already find solution? because in google there is no answers at all.
I found a similar problem in chat here https://github.com/ccxt/ccxt/issues/1485. But it didn't help me. Do you use Houbi API sometimes?
actuallytwolamas
Member
**
Offline Offline

Activity: 69
Merit: 20

Lama


View Profile WWW
June 06, 2018, 06:51:03 PM
 #8

Which language are you making API requests? I'm digging deeper and looks like, Timestamp should be current request time, so you must generate timestamp on request. Have you looked at their REST API Demos? Here is url https://github.com/huobiapi/REST-API-demos
ilya1966 (OP)
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
June 06, 2018, 08:29:04 PM
 #9

Which language are you making API requests? I'm digging deeper and looks like, Timestamp should be current request time, so you must generate timestamp on request. Have you looked at their REST API Demos? Here is url https://github.com/huobiapi/REST-API-demos

I found the problem - the time should be strictly Greenwich (UTC-0) time without any offsets.
Thank you for your help!

I sends API in PHP and C#. If you need something - I'm always ready to help.
izooomrud
Full Member
***
Offline Offline

Activity: 384
Merit: 150


View Profile
June 05, 2019, 06:12:08 AM
 #10

i have same trouble and i set (UTC -0) but it's doesn't not work
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!