请问我按照 chrome 的 request 提取数据用C# RestSharp 做博客园本地上传图片API功能,结果是失败的,请问我以下代码错在哪边呢?
或是大神们有更好的做法?
var filePath = @"C:\Users\xxxx\Downloads\Snipaste_2020-08-21_15-56-36.jpg";
var fileName = filePath.Split('\\').Last();
var client = new RestClient($"https://upload.cnblogs.com/imageuploader/CorsUpload");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("origin", "https://q.cnblogs.com");
request.AddHeader("referer", "https://q.cnblogs.com/q/new");
request.AddHeader("cookie", "涉及资安");
request.AddFile("imageFile", File.ReadAllBytes(filePath), Path.GetFileName(filePath));
request.AddParameter("host", "www.cnblogs.com");
request.AddParameter("uploadType", "Paste");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
用fiddler =>raw;然后用tcp写进去