获取StatusCode:UnsupportedMediaType用于文件上传。我正在使用带有承载令牌的RestClient
我成功获得了承载令牌,但是当将JSON发送到API时,却得到了不受支持的异常媒体类型
var client = new RestClient(requestAPIURL);
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", string.Format("Bearer " +
token.AccessToken));
request.AddParameter("application/json",
JsonConvert.SerializeObject(jsonData), ParameterType.RequestBody);
var response = client.Execute(request);
答案 0 :(得分:0)
POST
在请求正文中的JSON
:
request.AddBody(JsonConvert.SerializeObject(jsonData));