Reputation: 1534
I'm trying to send HEAD request to server to get a file length from Content-Length header, but I always get 'Not Acceptable' in response when I'm using RestSharp. Id I create request with simple .NET WebRequest it work good.
I tried to clear all header and other stuff from request and client, but had no success
Is it possible to do this request with RestSharp and how?
Thanks in advance
Upvotes: 0
Views: 1042
Reputation: 1534
Solved the problem with
restRequest.Parameters.Clear();
restRequest.AddHeader("Accept", "*/*");
Upvotes: 0
Reputation: 261
I'm using the following approach if someone is interested:
using RestSharp;
var client = new RestClient("/resource");
var request = new RestRequest();
var response = client.Head(request);
Upvotes: 0
Reputation: 8429
Try this
var request = new RestRequest("/resource", Method.HEAD);
Upvotes: 2