0
votes

I'm creating an app using .NET in c# to create cards on a Trello board but I can't make updates to the custom fields. I already scoured the API documentation and the internet but cannot make it work.

The code that I'm using to update the custom field value on the card is the following:

private static async Task<String> PutCustomFieldsAsync(string Url, string jsonContent)
{
    using (var httpClient = new HttpClient())
    {
        var response = await httpClient.PutAsync(Url, new StringContent(jsonContent, System.Text.Encoding.UTF8, "application/json"));
        json = await response.Content.ReadAsStringAsync();
    };

    return json;
}

The values of the variable are the following:

Url: "https://api.trello.com/1/cards/6...3fe/customField/5...bb9/item?key=4...f&token=e...6"

jsonContent: "{"Value":{"text":"test"}}"

When I set the field manually on Trello and then get the card customfields the JSON that comes out has the following data:

{
    "id": "6...c66",
    "value": {
      "text": "teste"
    },
    "idCustomField": "5...bb9",
    "idModel": "6...3fe",
    "modelType": "card"
  }

The response that I'm getting is "400 Bad Request" due to "Invalid value for custom field type".

Can anyone help me get this to work?

Thanks.

I've rolled back your edit. It is not appropriate to add the answer to your question into the question itself. Instead, you should write an answer in the space below provided for that purpose. For more information, see Can I answer my own question?. - Ken White