How to send a POST Request to a web service without data from console application in C#?

I have a requirement in my Google cloud Storage project to make a POST request with empty body along with some request headers and get the Created(201) response , which contains an Upload ID to initiate resumable uploads.

I could find references to send POST request with data , but not without data from console application.

Does any one know how to get through this problem.

Answers


    using(var http = new WebClient())
    {
        http.Headers.Add("headername", "headervalue");
        var response = http.UploadData(address, new byte[0]);
    }

The Google Cloud Storage online docs contain a section describing the resumable upload protocol (link). it includes the following sample request for initiating a resumable upload:

POST /music.mp3 HTTP/1.1
Host: example.commondatastorage.googleapis.com
Date: Fri, 01 Oct 2010 21:56:18 GMT
Content-Length: 0
Content-Type: audio/mpeg
x-goog-resumable: start
x-goog-api-version: 2
Authorization: OAuth 1/zVNpoQNsOSxZKqOZgckhpQ

You could also take a look at the boto source code, which contains a Python implementation of the Google Cloud Storage resumable upload protocol (see boto/gs/resumable_upload_handler.py).


Need Your Help

jquery, get url segment - ajax

javascript jquery ajax

Say I have a list of items from a database. Next to each item there is a delete link. the links look something like: http://example.com/exp/delete/1 - 1 is the ID of the record I want to delete. Ho...

Permission probllem gaining access to a temp folder

php google-app-engine silverstripe

I am trying to get SilverStripe to work on Google-App-Engine but it give this error: