Arseni Mourzenko
Arseni Mourzenko

Reputation: 52371

How to make an HTTP request using a custom verb?

In order to test an API, I want to be able to make HTTP requests using custom verbs (such as "RECOMPUTE")¹, other than GET, POST, PUT, DELETE, OPTIONS, HEAD, TRACE and CONNECT.

Is there a library which already does that, or do I have to reinvent the wheel using HttpWebRequest and HttpWebResponse?

Answers to another, less specific question, suggest several libraries, none being compatible with what I need:


¹ In anticipation of comments such as "Using non-standard verbs is a bad idea", there is nothing I can do with that. I'm using a private API where the choice was made to use custom verbs.

Upvotes: 2

Views: 3717

Answers (1)

Mikael Östberg
Mikael Östberg

Reputation: 17176

Take a look at the System.Net.Http.HttpClient class in .NET 4.5. Not only does it support the common ones, but it allows you to specify your own method as well.

Construct your own verb by using the HttpMethod class.

var method = new HttpMethod("RECOMPUTE");

Docs:

Upvotes: 3

Related Questions