RestClient(Restsharp) ContentType setting and HttpBaseAuth setting tricky.

var request = new RestRequest(baseUri + urlListEndPoint, Method.PUT);
var jsonUrls = JsonConvert.SerializeObject(fakeList);


1.

//request.AddHeader("Authorization", "Basic cHJ4d29vcHVveWR1cHZrcHA0eHd6YXptZjZ3OHVxemQ6");   //这个是工作的,前提是你有了Base64 的 username:password
//request.AddHeader("Content-Type", "application/octet-stream");  //这个有问题,无效



2.

 public static readonly RestClient _client = new RestClient() { Authenticator = new HttpBasicAuthenticator(username,password) };

//这个也是工作的,在Client上直接加授权,

request.AddHeader("Accept", "application/octet-stream");
request.AddParameter("application/octet-stream", jsonUrls, ParameterType.RequestBody);

//如果要加Content-type,要加上  以上2句话



http://stackoverflow.com/questions/17815065/set-content-type-header-using-restsharp

你可能感兴趣的:(RestClient(Restsharp) ContentType setting and HttpBaseAuth setting tricky.)