title: Error while creating a WorkItem via API - Devops
body: <p>I'm trying to create a workitem via API, but im getting the following error:</p>
  <pre><code>{
    &quot;innerException&quot;: null,
    &quot;message&quot;: &quot;You must pass a valid patch document in the body of the request.&quot;,
    &quot;typeName&quot;: &quot;Microsoft.VisualStudio.Services.Common.VssPropertyValidationException, Microsoft.VisualStudio.Services.Common&quot;,
    &quot;typeKey&quot;: &quot;VssPropertyValidationException&quot;,
    &quot;errorCode&quot;: 0,
    &quot;eventId&quot;: 3000
  }
  </code></pre>
  <p>Code:</p>
  <pre><code>public class Chamados
      {
          public async Task&lt;string&gt; CriaChamadoDevOps()
          {
              string organizacao = &quot;xxx&quot;;
              string departamento = &quot;xxx&quot;;
              string tipoWorkItem = &quot;xxx&quot;;
              string authToken = &quot;xxx&quot;;
  
              // Montando a Requisição
              string urlReq = &quot;https://dev.azure.com/&quot; + organizacao + &quot;/&quot; + departamento + &quot;/_apis/wit/workitems/$&quot; + tipoWorkItem + &quot;?api-version=6.0&quot;;
              var client = new RestClient(urlReq);            
              var request = new RestRequest(urlReq, Method.Post);
  
              // Montando Headers
              request.AddHeader(&quot;Authorization&quot;, &quot;Basic &quot; + Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Format(&quot;{0}:{1}&quot;, &quot;&quot;, authToken))));            
              request.AddHeader(&quot;Content-Type&quot;, &quot;application/json-patch+json; charset=utf-8&quot;);            
  
              var body = new JArray {
                  new JObject {
                      { &quot;op&quot;, &quot;add&quot; },
                      { &quot;path&quot;, &quot;/fields/System.Title&quot; },
                      { &quot;value&quot;, &quot;Assunto Teste&quot; }
                  },
                  new JObject {
                      { &quot;op&quot;, &quot;add&quot; },
                      { &quot;path&quot;, &quot;/fields/System.State&quot; },       
                      { &quot;value&quot;, &quot;To do&quot; }
                  },
                  new JObject {
                      { &quot;op&quot;, &quot;add&quot; },
                      { &quot;path&quot;, &quot;/fields/System.Description&quot; },                    
                      { &quot;value&quot;, &quot;Descricao Teste&quot; }
                  },                
              };
  
              //request.AddBody(body);
              request.AddParameter(&quot;application/json-patch+json; charset=utf-8&quot;, body, ParameterType.RequestBody);            
              Console.WriteLine(body);            
              RestResponse response = await client.ExecuteAsync(request);
              dynamic resposta = JsonConvert.DeserializeObject(response.Content);
  
              return resposta.ToString();
          }
      }
  </code></pre>
  <p>When i test it via Postman, it works.</p>
  <p>This is how im sending the body to the request:
  (Output from Console.WriteLine(body);)</p>
  <pre><code>[
    {
      &quot;op&quot;: &quot;add&quot;,
      &quot;path&quot;: &quot;/fields/System.Title&quot;,
      &quot;value&quot;: &quot;Assunto Teste&quot;
    },
    {
      &quot;op&quot;: &quot;add&quot;,
      &quot;path&quot;: &quot;/fields/System.State&quot;,
      &quot;value&quot;: &quot;To do&quot;
    },
    {
      &quot;op&quot;: &quot;add&quot;,
      &quot;path&quot;: &quot;/fields/System.Description&quot;,
      &quot;value&quot;: &quot;Descricao Teste&quot;
    }
  ]
  </code></pre>
  <p>And i've also tried replacing the &quot;request.AddParameter()&quot; with &quot;request.AddBody()&quot; method.</p>