Bitcoin Forum
May 24, 2024, 05:54:45 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: cryptsy api unknown method error  (Read 2433 times)
nubas (OP)
Newbie
*
Offline Offline

Activity: 28
Merit: 0


View Profile
July 06, 2013, 07:40:35 PM
 #1

DateTime dt = DateTime.Now;
            int tick = dt.Year + dt.Month + dt.Day + dt.Hour + dt.Minute + dt.Second + dt.Millisecond;

            string par = "method=getinfo&nonce=" + tick.ToString();
            byte[] parBytes = encoding.GetBytes(par);
            var keyByte = encoding.GetBytes(privKey + par);

            var hmac = new HMACSHA512(keyByte);
            string finalPass = BitConverter.ToString(hmac.Key, 0).Replace("-", "");

            string url = "https://www.cryptsy.com/api.php";

            var webRequest = (HttpWebRequest)WebRequest.Create(url);
            webRequest.Credentials = new NetworkCredential(pubKey, finalPass);
            if (webRequest != null)
            {
                webRequest.Method = "POST";

                Stream newStream = webRequest.GetRequestStream();
                // Send the data.
                newStream.Write(parBytes, 0, parBytes.Length);
                newStream.Close();

                var httpResponse = (HttpWebResponse)webRequest.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    var result = streamReader.ReadToEnd();
                }


why i always get in result: {"success":0,"error":"unknown method"}
scintill
Sr. Member
****
Offline Offline

Activity: 448
Merit: 254


View Profile WWW
July 07, 2013, 02:54:45 AM
 #2

Since nobody else has answered yet, here's a guess: maybe you need to set the POST body content-type.  If this is C#/.NET, try setting the HttpWebRequest object's ContentType and maybe also ContentLength as shown in the example code here.

1SCiN5kqkAbxxwesKMsH9GvyWnWP5YK2W | donations
monsterer
Legendary
*
Offline Offline

Activity: 1008
Merit: 1002


View Profile
July 07, 2013, 11:11:43 AM
 #3

Does this shed any light:

Code:
[b]Authenticated Methods [/b]
Authenticated methods require the use of an api key and can only be accessed via the POST method.

URL - The URL you will be posting to is: https://www.cryptsy.com/api (notice it does NOT have the '.php' at the end)

?
MarpleTrading
Full Member
***
Offline Offline

Activity: 191
Merit: 100


View Profile WWW
August 31, 2013, 11:07:35 AM
 #4

Have you solved this problem, very interested in how.

Also sent you a PM.

An easy to use API for price information from the most import crypto exchanges
https://www.cryptodb.com
abwaters
Newbie
*
Offline Offline

Activity: 9
Merit: 0


View Profile
December 28, 2013, 02:22:14 AM
 #5

You need to send the arguments "method" and "nonce" as post arguments.  You will also want to set Content-Type as application/x-www-form-urlencoded and set the HTTP headers Key and Sign. 

Take a look at the Crypsty.java method authrequest() in the following github repository for a java example.  If you rework your code i'll be glad to help you debug it.

https://github.com/abwaters/cryptsy-api

-bryanw
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!