You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
I am able to successfully get all the cards and custom fields from my board using:
string qString = @"https://api.trello.com/1/boards/{boardId}/cards?customFieldItems=true&key={myKey}&token={myToken}"; using(var request = new HttpRequestMessage(new HttpMethod("GET"), qString))
{
var response = await httpClient.SendAsync(request);
String JsonString = await response.Content.ReadAsStringAsync();
but now I want to Set one of those custom fields. I've tried this but it doesn't work:
using(var httpClient = new HttpClient())
{ using(var request = new HttpRequestMessage(new HttpMethod("PUT"), @"https://api.trello.com/1/cards/" + myCardId + "/" + myCustomFieldId + "/item?" + "key={myKey}&token={myToken}" + "{value: { text: \"New Value\"}}"))
{
// i don't know how to set the header content so i commented it out
//request.Headers.Add("content-type", "application/json");
var response = await httpClient.SendAsync(request);
String JsonString = await response.Content.ReadAsStringAsync();
Thjanks,
Dave
@David Funni I code using python wrapper for Trello API so I am not familiar with c#. First Trello CF definitions are kept at the board level. So you need to use this
GET /1/boards/{id}/customFields
Get the Custom Field Definitions that exist on a board.
in the first part of your code to get CF definitions. As such I believe that your myCustomFieldID not the id of the CF text field you want to set.
For the second part the API should be
PUT /1/cards/{idCard}/customField/{idCustomField}/item
Setting, updating, and removing the value for a Custom Field on a card.
I see that I can get the custom field definitions for the board. And I do. And each one has an Id.
When I get the cards for the board I can request that it give me the card's custom field items also. So I do. And each of those has an Id and an IdCustomField. The Id is a unique Id of this field in this card, whereas the IdCustomField is equal to the corresponding custom field Id in the board.
I'm not sure which Id to use in my PUT though...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@David Funni the equivalent in py-Trello for what you are doing is likely this:
def set_custom_field(self, value, custom_field):
in the code for PUT the definition ID is used.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When I put that line in, I get this exception:
System.InvalidOperationException: 'Misused header name. Make sure request headers are used with HttpRequestMessage, response headers with HttpResponseMessage, and content headers with HttpContent objects.'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I do believe I need to figure that out though as the error message I get back has my Json string all converted to some ascii representation or something like that:
Cannot PUT /1/cards/{cardId}/{CustomFieldId}/item?key={myKey}&token={myToken}%7Bvalue:%20%7Btext:%20%22TestName%22%7D%7D
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@David Funni you might find the specifics of how to format the request here:
https://github.com/gregsdennis/Manatee.Trello
or you could just use that lib :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your guy's help.
I was able to figure out my question using this website which converts Curl to C#:
private async void button4_Click(object sender, EventArgs e) { using(var httpClient = new HttpClient()) { String querry = @"https://api.trello.com/1/card/" + myCardId + "/customField/" + myCardsCustomFieldItems_IdCustomField + "/item"; using(var request = new HttpRequestMessage(new HttpMethod("PUT"), querry)) { request.Content = new StringContent("{ \"value\": { \"text\": \"Hello, world!\" }, \"key\": \"########\", \"token\": \"#######\" }"); request.Content.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); var response = await httpClient.SendAsync(request); String JsonString = await response.Content.ReadAsStringAsync(); this.textBox4.Text = querry; this.richTextBox4.Text = JsonString; } } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Community! My name is Brittany Joiner and I am a Trello enthusiast and Atlassian Community Leader. I'll be sharing with you a series of videos with my top tips on how to best use Trello...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.