Bitcoin Forum
November 02, 2024, 04:30:16 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: rpc.blockchain.info Json-rpc Cant get it to work, help  (Read 5169 times)
elroy69 (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
June 06, 2014, 07:27:15 PM
 #1

Hi I am hoping someone out there has a answer to this.

For the life of me I can not get a proper response from posting to https://rpc.blockchain.info:443 All I ever get back looks like:

This is what I send -> "{"id":"1","method":"getinfo","params":[],"jsonrpc":"2.0\"}"

This is what I always get back -> {"error":{"message":"JSON-RPC method [getinfo] with 0 parameters not found.","code":-32601},"jsonrpc":"2.0"}

Is there some kind of HTTP Post Credentials that need to be set some special way?

Does anyone have some examples you could post that you know work for sure?  Is there a simple HTTP Post Send Headers and all that you could post, which you know works and get the right response back.

Driving me nuts, thank is advance for your help.
jagallout
Newbie
*
Offline Offline

Activity: 29
Merit: 0


View Profile
June 07, 2014, 03:43:48 AM
 #2

Hi there,
I too noticed a few days ago that blockchains rpc api appeared to be not working correctly.  It was because of this that I created a local VM and syncd the blockchain for local testing.  I cannot say that my code would for sure work on blockchain.info, but IT DOES work on my local bitcoind.

To answer your question, per their documentation: https://blockchain.info/api/json_rpc_api
you DO need to authenticate:

Authentication
-rpcuser Should be set to your wallet identifier. This is a 36 character random string which can be found on your wallet login page.
-rpcpassword Should be set to your main wallet password. If double encryption is enabled your second password will need to be set using walletpassphrase

I ran three tests using the three different Uris you see in the below code snippet - Results after code.  Its in powershell 4.0, in case your curious.

Code:
$cred = Get-Credential
#$Uri = "http://127.0.0.1:8332"
#$Uri = "http://rpc.blockchain.info:80"
$Uri = "https://rpc.blockchain.info:443"

$p_jsonrpc = "`"jsonrpc`":2.0"
$p_id = "`"id`":1"

function execute
{
   param
   (
    $json
   );

    Write-Host "Connecting to $Uri"
    $result = Invoke-WebRequest -Uri $Uri -Method Post -ContentType "application/json-rpc" -Credential $cred -Body $json
    return $result.Content
}

function getInfo
{
    $json =
@"
{"method":"getinfo",$p_id, $p_jsonrpc}
"@
    Write-Host "Executing getinfo"
    return execute($json)

}

getinfo

--------------POWERSHELL TRANSACTION-----------------
.\Powershell\bitcoin\bitcoinRPCtest.ps1
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Executing getinfo
Connecting to http://127.0.0.1:8332

{"result":{"version":90100,"protocolversion":70002,"walletversion":60000,"balance":0.00000000,"blocks":79730,"timeoffset":-1,"connections":8,"proxy":"","difficulty":712.88486455,"testnet":fal
se,"keypoololdest":1402111629,"keypoolsize":101,"paytxfee":0.00000000,"errors":""},"error":null,"id":1}


.\Powershell\bitcoin\bitcoinRPCtest.ps1
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Executing getinfo
Connecting to http://rpc.blockchain.info:80

{"error":{"message":"JSON-RPC method [getinfo] with 0 parameters not found.","code":-32601},"jsonrpc":"2.0"}

.\Powershell\bitcoin\bitcoinRPCtest.ps1
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Executing getinfo
Connecting to https://rpc.blockchain.info:443

{"error":{"message":"JSON-RPC method [getinfo] with 0 parameters not found.","code":-32601},"jsonrpc":"2.0"}
elroy69 (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
June 10, 2014, 10:06:48 PM
 #3

jagallout:

Thank you very much for you efforts and reply on this.

Were you ever able to get it to work with blockchain.info?  That is the secret I am look for.

I am not sure what is the small issue we are both missing.  Any ideas on what might be the difference?  Can you post the exact json you posted?

Thanks.
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!