Bitcoin/PIVX JSON-RPC and CURL just returns Unauthorized
No matter what I try, I cannot get a request to PIVX wallet / Blockchain Api. It works 100% in curl from CMD.
curl --user user:pass --data-binary "{\"jsonrpc\": \"1.0\", \"id\": \"curltest\", \"method\": \"mnbudget\", \"params\": [\"show\"]}" -H \"content-type:text/plain;\" http://localhost:51473
(where user:pass are my rpcusername and rpcpassword in pivx.conf)
I've also tried a request in this format:
curl --data-binary "{\"jsonrpc\": \"1.0\", \"id\": \"curltest\", \"method\": \"mnbudget\", \"params\": [\"show\"]}" -H \"content-type:text/plain;\" http://user:pass@localhost:51473
The JSONRPC request from their docs (https://github.com/PIVX-Project/PIVX/wiki/API-Reference-JSON-RPC) in the .NET section throws Unauthorized, so does it if I try a standard webrequest.
I'm making the request it from my application (local on my win10 dev pc) to pivxd / bitcoind (same thing) also running on my pc.
I'm under deadline and have taken nearly 2 weeks trying to get this to work!! I've never done this before. Please help!
this is my latest attempt (I've tried SO MANY ways)
public void GetBlockchainProposals() { try { var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://user:pass@localhost:51473"); httpWebRequest.ContentType = "text/plain"; httpWebRequest.Method = "POST"; using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { string json; json = "{ \"jsonrpc\": \"1.0\", \"id\":\"curltest\", \"method\": \"getinfo\",\"params\":[]}"; streamWriter.Write(json); } var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var responseText = streamReader.ReadToEnd(); } } catch(Exception ex) { this.Logger.LogCritical(ex, $"{ex.InnerException}"); // Unauthorized } }https://ift.tt/2Pjkge2
Comments
Post a Comment