C# 通过RESTAPI添加注释以强化问题会导致内容编码错误

C# 通过RESTAPI添加注释以强化问题会导致内容编码错误,c#,.net,rest,fortify,C#,.net,Rest,Fortify,我正试图对Fortify中的一个问题添加评论。当我发布我认为正确的JSON时,我收到响应“{”消息“:“内容格式不正确(预期为application/JSON;charset=utf-8)。”,“responseCode”:400,“errorCode”:-20209}” 然而,如果我使用Fiddler检查我正在发布和接收的消息,相应的标题似乎已经就位。引发此异常的第二个问题是什么 强化v18.10.0187 .NET v4.6.2 Newtonsoft.Json v9.0.0 public

我正试图对Fortify中的一个问题添加评论。当我发布我认为正确的JSON时,我收到响应“{”消息“:“内容格式不正确(预期为application/JSON;charset=utf-8)。”,“responseCode”:400,“errorCode”:-20209}”

然而,如果我使用Fiddler检查我正在发布和接收的消息,相应的标题似乎已经就位。引发此异常的第二个问题是什么

强化v18.10.0187
.NET v4.6.2
Newtonsoft.Json v9.0.0

 public static string PostCommentIssue(FortifyComment fc)
 {
      var content = JsonConvert.SerializeObject(fc);
      var postUri = String.Format(Configuration.FortifyCommentsUri, fc.data.issueId);
      return WebServiceHelper.PostMessage(postUri, content);
 }

 public static string PostMessage(string url, string content)
 {
      HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, url);
      requestMessage.Headers.Add("Authorization", Configuration.FortifyAuthorization.ToHeader());
      requestMessage.Content = new StringContent(content, Encoding.UTF8, JsonMediaTypeFormatter.DefaultMediaType.MediaType);

      HttpResponseMessage hrm = HttpClient.SendAsync(requestMessage).Result;
      hrm.EnsureSuccessStatusCode();
      HttpContent hc = hrm.Content;

      return hc.ReadAsStringAsync().Result;
 }
FortifyComment只是一个包含注释基本元素的对象。它基于对查询(因此是内部数据元素)给出的强化响应

使用

我收到400错误。Fiddler截取的屏幕截图:

 FortifyComment fc = new FortifyComment();
 fc.data.issueId = defect.id;
 fc.data.comment = String.Format("TFS #{0}.", tfsNumber);
 FortifyHelper.PostCommentIssue(fc);