How to make POST request on C to blockr io

0 votes

Trying to write a method to push a TX. 

According to the documentation from blockr, I'm supposed to do this:

To publish a transaction make a POST (!) request with your transaction hex to the push API.

Using curl this would be like (shell example):

curl -d '{"hex":"TX_HASH"}' 

I am using the following C# code:



    public static void Post(string RequestURL, string Post1, string Post2)
    {
        using (var wb = new WebClient())
        {
            var data = new NameValueCollection();
            data[Post1] = Post2;
            var response = wb.UploadValues(RequestURL, "POST", data);
        }
    }

But i get a lot of errors

Aug 30, 2018 in Blockchain by slayer
• 29,370 points
1,751 views

1 answer to this question.

0 votes

By default UploadValues doesn't format the data in json, you could format it yourself:

public static void Post(string RequestURL, string Post1, string Post2)
{
    using (var wb = new WebClient())
    {
        var data = string.Format("{0}\"{1}\":\"{2}\"{3}", "{", Post1, Post2, "}");
        var response = wb.UploadString(RequestURL, "POST", data);
    }
}

Or use a JSON serializer such as NewtonSoft

answered Aug 30, 2018 by digger
• 26,740 points

Related Questions In Blockchain

0 votes
1 answer

How to make my Dapp work on regular browsers?

There are ethereum supporting browsers like Metamask, ...READ MORE

answered Jun 20, 2018 in Blockchain by aryya
• 7,460 points
632 views
0 votes
1 answer

How to trigger change blockchain network request on MetaMask

was finally able to find the answer: await ...READ MORE

answered Mar 31, 2022 in Blockchain by Rahul
• 9,680 points
1,006 views
0 votes
1 answer

How to make sure transactions take no fee in a private Ethereum blockchain?

In a private ethereum network you have ...READ MORE

answered Mar 26, 2018 in Blockchain by Christine
• 15,790 points

edited Mar 26, 2018 by Christine 1,574 views
+1 vote
1 answer

How to deploy ethereum smart contracts on a website?

There are many ways to do this: 1 ...READ MORE

answered Mar 27, 2018 in Blockchain by Johnathon
• 9,090 points
1,962 views
+1 vote
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,460 points
1,434 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
1,928 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,456 views
0 votes
1 answer

How to return data on execution of invoke function?

You can do this using a response ...READ MORE

answered Jul 23, 2018 in Blockchain by digger
• 26,740 points
635 views
0 votes
1 answer

Google API post request to IBM blockchain error

You have specified query as parameter to method and function but if you ...READ MORE

answered Sep 14, 2018 in Blockchain by digger
• 26,740 points
597 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP