Bitcoin Forum
April 25, 2024, 05:40:00 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Consuming JSON-RPC from Bitcoin using .net  (Read 5240 times)
swinewine (OP)
Newbie
*
Offline Offline

Activity: 44
Merit: 0



View Profile WWW
December 09, 2010, 04:30:56 PM
 #1

Hi guys,

Does anyone have any experience Consuming JSON-RPC from Bitcoin using (c#) .net?
I have been trying to get a basic application to work using jayrock but I cant get any of the methods to return JSON to me.

Any help here would be appreciated.

Cheers,

BC
1714066800
Hero Member
*
Offline Offline

Posts: 1714066800

View Profile Personal Message (Offline)

Ignore
1714066800
Reply with quote  #2

1714066800
Report to moderator
1714066800
Hero Member
*
Offline Offline

Posts: 1714066800

View Profile Personal Message (Offline)

Ignore
1714066800
Reply with quote  #2

1714066800
Report to moderator
1714066800
Hero Member
*
Offline Offline

Posts: 1714066800

View Profile Personal Message (Offline)

Ignore
1714066800
Reply with quote  #2

1714066800
Report to moderator
Unlike traditional banking where clients have only a few account numbers, with Bitcoin people can create an unlimited number of accounts (addresses). This can be used to easily track payments, and it improves anonymity.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714066800
Hero Member
*
Offline Offline

Posts: 1714066800

View Profile Personal Message (Offline)

Ignore
1714066800
Reply with quote  #2

1714066800
Report to moderator
1714066800
Hero Member
*
Offline Offline

Posts: 1714066800

View Profile Personal Message (Offline)

Ignore
1714066800
Reply with quote  #2

1714066800
Report to moderator
1714066800
Hero Member
*
Offline Offline

Posts: 1714066800

View Profile Personal Message (Offline)

Ignore
1714066800
Reply with quote  #2

1714066800
Report to moderator
swinewine (OP)
Newbie
*
Offline Offline

Activity: 44
Merit: 0



View Profile WWW
December 09, 2010, 04:52:40 PM
 #2

Hi davidonpda thanks for the response,

Yes I am running it with -server and I am able to access the commands via the command line.
I am able to authenticate but when I make a JSON-RPC call to bitcoin I get no errors.
Have you ever tried this with .net/jayrock or any other .net package ?

Thanks again,

BC
swinewine (OP)
Newbie
*
Offline Offline

Activity: 44
Merit: 0



View Profile WWW
December 09, 2010, 05:06:38 PM
 #3

Bingo!

Im ok now, I think I am on top of it.
kkinnett
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
February 28, 2011, 06:55:58 PM
 #4

What was your issue and how did you resolve it? I am trying to do the same thing, and have username and password set, and the allowed ip set to *.*.*.*

I keep sending out a request like this
{"id":"1","method":"getinfo","params":[]}

but i am constantly getting back this
{"result":null,"error":{"code":-32700,"message":"Parse error"},"id":null}

any clue on what I am doing wrong?
Gavin Andresen
Legendary
*
qt
Offline Offline

Activity: 1652
Merit: 2216


Chief Scientist


View Profile WWW
February 28, 2011, 07:32:30 PM
 #5

Are you setting the ContentType as described here:
  https://en.bitcoin.it/wiki/API_tutorial_(JSON-RPC)#.NET_(C_)

How often do you get the chance to work on a potentially world-changing project?
kkinnett
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
February 28, 2011, 08:01:27 PM
Last edit: February 28, 2011, 08:12:49 PM by kkinnett
 #6

I am, yes.


            WebRequest request = GetWebRequest(new Uri(Url));
            request.Method = "POST";
            request.ContentType = "application/json-rpc";
            request.Credentials = new NetworkCredential("<myuser>", "<mypass>");

I am creating the request via the JayRock JsonObject type.

            using (var stream = request.GetRequestStream())
            using (var writer = new StreamWriter(stream, Encoding.UTF8))
            {
                var call = new JsonObject();
                call["id"] = Convert.ToString(++_id);
                call["method"] = method;
                call["params"] = args;
                call.Export(new JsonTextWriter(writer));
            }

Thanks very much for the reply BTW :-)
BitterTea
Sr. Member
****
Offline Offline

Activity: 294
Merit: 250



View Profile
February 28, 2011, 08:18:30 PM
 #7

You can take a look at my sources here: https://github.com/Fnordsoft/Bitcoin-Projects/tree/master/Libraries/Bitcoin/src/JSON-RPC

I didn't want to use a JSON library, so I decided to write my own wrapper. It seems to work ok, at least for Bitcoin, though it is not complete.
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!