GitLabApiClient icon indicating copy to clipboard operation
GitLabApiClient copied to clipboard

Can't create issue note.

Open hhko opened this issue 4 years ago • 0 comments

Sample Code

static async Task Main(string[] args)
{
      var gitLabClient = new GitLabClient("http://www.gitlab.com/", "------");
      Project project = await gitLabClient.Projects.GetAsync("-----");

      await gitLabClient.Issues.CreateNoteAsync(project.Id, 10, new CreateIssueNoteRequest
      {
          Body = "Hello!"
      });
}
  • The number of issue is 10. image

Exception

image

  • message
Newtonsoft.Json.JsonSerializationException: 
'Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'GitLabApiClient.Models.Notes.Responses.Note' 
because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.

To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. 

JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
  • reference code
    • GitLabApiClient.Internal.Http.Serialization.RequestsJsonSerializer.Deserialize<T>(string) in JsonSerializer.cs
    • GitLabApiClient.Internal.Http.GitLabApiRequestor.ReadResponse<T>(System.Net.Http.HttpResponseMessage) in GitlabApiRequestor.cs

hhko avatar May 05 '20 08:05 hhko