XMLHttpRequest is not defined while sending request to blockchain service via C#

0 votes

I'm trying to request the balance from https://blockchain.info/. Following instructions https://github.com/blockchain/service-my-wallet-v3#installation I've installed node.js and npm and successfully started the server. Now I'm trying to request the balance of my wallet:

string responseString;
string urlRequest = "http://127.0.0.1:3000/api/v2/create";
var request = (HttpWebRequest)WebRequest.Create(urlRequest);

request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";

string requestData = "password=PASS&api_code=CODE";
byte[] dataStream = Encoding.UTF8.GetBytes(requestData);
request.ContentLength = dataStream.Length;
Stream newStream = request.GetRequestStream();
newStream.Write(dataStream, 0, dataStream.Length);
newStream.Close();
var response = (HttpWebResponse)request.GetResponse();
responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
Console.WriteLine(responseString);
return responseString;

But I get response 500 and in node.js command prompt written "Error generating the entropyReferenceError: XMLHttpRequest is not defined.

Sep 20, 2018 in Blockchain by digger
• 27,620 points
57 views

1 answer to this question.

0 votes

use post data in url link and it worked:

string responseString;
string urlRequest = "http://127.0.0.1:3000/merchant/WALLET_ID/balance?password=PASS&api_code=API_CODE";
var request = (HttpWebRequest)WebRequest.Create(urlRequest);

request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
var response = (HttpWebResponse)request.GetResponse();
responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
Console.WriteLine(responseString);
return responseString;
answered Sep 20, 2018 by slayer
• 29,050 points

Related Questions In Blockchain

0 votes
1 answer
+1 vote
3 answers

Is it possible to store data about arbitrary objects on the blockchain using smart contracts?

Consider following tutorial from Hyperledger Fabric "Getting Started" pages. Basically ...READ MORE

answered Aug 30, 2018 in Blockchain by Artem
90 views
+1 vote
1 answer

I would like to create a blockchain network which will stay at the same level of complexity, is it possible?

You can very easily create a cryptocurrency having a ...READ MORE

answered Apr 4, 2018 in Blockchain by Christine
• 15,790 points
33 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
104 views
0 votes
1 answer
+1 vote
5 answers

How to solve "truffle: command not found" error in blockchain?

First try restarting the system and then ...READ MORE

answered Jul 16, 2018 in Blockchain by slayer
• 29,050 points
669 views