Error when updating desc og only if desc is empty?

Hi All,

My problem occurs when:

  1. I create a Card in Trello and name it “Test Card”
  2. With the Trello API I update the Card desc with “test”

Error: The description is not updated???

It works if I do this:

  1. I create a Card in Trello and name it “Test Card”
  2. Open the Card and click “Save” on the description (With empty content)
  3. With the Trello API I update the desc with “test”

Works fine…

Here is my php code:

var data = {
name: ‘Test Card’,
desc: ‘test’,
};

var xhr = new XMLHttpRequest();

xhr.addEventListener(“readystatechange”, function () {
if (this.readyState === this.DONE) {
var response = JSON.parse(this.responseText);
console.log(response);
}
});

xhr.open(“PUT”, “https://api.trello.com/1/cards/” + cardId + “?key=” + appKey + “&token=” + token);
xhr.setRequestHeader(“Content-Type”, “application/json”);
xhr.send(JSON.stringify(data));

Does anybody have an idea?

Thanks in advance from Denmark,
John

Hello @JohnChristiansen

I cannot replicate that issue. If I create a card in Trello using the GUI and give it only a name, but no description, I can immediately find its ID via the REST API and then use the Update a Card endpoint to give it a description.

I think it’s just that your JSON body is faulty:

var data = {
name: ‘Test Card’,
desc: ‘test’, <-- THIS COMMA SHOULD NOT BE HERE
};

You have added an un-required comma after the desc object’s definition, so it’s being ignored.

Try just:

var data = {
desc: ‘test’
};

If this has no effect, what error messages are you getting back? What JSON response does the endpoint provide?

Also, are you able to change the name of the card via the REST API?

Thanks for trying, but that’s not the reason.

It should be simple, but I don’t know what is causing it to not update. As I said, update it fine - just the description has been saved first…

Sometimes I update the Card name and it also works fine once the description is been activated.

What do you mean by ‘sometimes’? Are you saying that updating of the card’s name via the REST API is subject to random operation, or are you saying you can’t update the name unless the description has been saved via the GUI??

You’re not providing any new, particularly insightful information to help, such as:

  1. Does this happen for every single card on every single board, or only certain cards in certain boards
  2. What error messages, if any, you are getting when you use the REST API to update the card?
  3. What’s in the resulting JSON responses from the call to that endpoint?
  4. What happens when you use an API test tool like Postman to check your requests to that same endpoint separately to your code.
  5. When you look at the Card’s event log, do you see evidence of the changes being attempted?
  6. Have you checked to make sure a Butler automation isn’t interfering with the process
  7. Are all others in your company with REST API access to Trello having the same problem?

etc, etc, etc, etc.

Start with basic debugging. Go step-by-step to isolate the issue to being either your method or your code, then do systematic tests to see what does work and what doesn’t work.

Thanks sunnyape :pray:

I have now found out where the problem is, but can´t find a solution.

When I create a new card and open it. The Card automatically starts with the Description open:

I then open a Model window by clicking on (Card Button) “Open Modal” under Power-Ups.
(I don’t Close, Save or Cancel the Description text input)

From the Modal I update the Card Description and close the modal again.

I then come back to the Card with the empty Description text input open.

If I click [Save] Trello saves the empty data from the text input.

If I click anywhere in the window, Trello saves the empty data from the text input.

Only if I click [Cancel] or close the window, the data I have entered in the Modal been retained.

I hope that explains my problem well enough :sweat_smile:

Does anyone have a solution for this?