Originally, I had thought that there was not a way to do this using RestSharp, since the IRestRequest
interface uses a Method
enum to represent the HTTP method. However, it appears that RestSharp does, in fact, support using non-standard HTTP verbs via the ExecuteAsGet<T>
and ExecuteAsPost<T>
methods on the RestClient
class. Which method you use depends on the semantics of the non-standard HTTP method. If the request has a body (or "entity" in HTTP parlance) then you would use ExecuteAsPost
; if it does not, then you would use ExecuteAsGet
.
Here is some sample code demonstrating how to use RestSharp to do a LINK request, based on one of the examples in the draft memo referenced in your question.
RestClient client = new RestClient("http://example.org");
RestRequest request = new RestRequest("/images/my_dog.jpg");
request.AddHeader("Link", "<http://example.org/profiles/joe>; rel=\"tag\"");
IRestResponse response = client.ExecuteAsGet(request, "LINK");
Debug.WriteLine((int)response.StatusCode + " " + response.StatusDescription);
UPDATE
It seems you are right, the WP8 project does not include RestClient.Sync.cs
, which contains the synchronous ExecuteAsGet<T>
and ExecuteAsPost<T>
methods. However there are asynchronous versions, ExecuteAsyncGet<T>
and ExecuteAsyncPost<T>
which should be available to you in WP8. Both of these accept a string httpMethod
parameter as well.
client.ExecuteAsyncGet(request, (response, handle) =>
{
Debug.WriteLine((int)response.StatusCode + " " + response.StatusDescription);
},
"LINK");