Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

249
Views
¿Cómo enviar objetos en JavaScript con Trello API? (Solicitud XMLHttp)

Soy nuevo en JavaScript. Pude enviar algunas solicitudes PUT, el problema es que ninguna de ellas me hizo enviar un objeto. ahora quiero enviar un objeto para agregar/cambiar la portada de una tarjeta en Trello (cambiar el color solo por ejemplo/agregar una portada), pero en la API de Trello, la portada es de tipo objeto. ¿Cómo puedo hacerlo con XMLHttpRequest?

mi solicitud PUT normal (funciona, aunque no para objeto):

 function updateCheckItem(cardId, checkItemId, state) { // state is boolean var url = "https://api.trello.com/1/cards/" + cardId + "/checkItem/" + checkItemId + "?key=...&token=...&state=" + state; var xhr = new XMLHttpRequest(); xhr.open("PUT", URL); xhr.setRequestHeader("Accept", "application/json"); xhr.setRequestHeader("Content-Type", "application/json"); xhr.onreadystatechange = function () { if (this.readyState == 4) { //do something not relevant } }; xhr.send(); }

ahora, ¿cómo debo enviar un objeto en lugar de algo como el estado booleano en el código anterior?

Busqué y encontré algo sobre JSON.stringify pero no funcionó para mí/no sabía exactamente cómo usarlo.

mi último intento fallido:

 function Cover(cardId) { var url = "https://api.trello.com/1/cards/" + cardId + "?key=...&token=...&cover"; var xhr = new XMLHttpRequest(); xhr.open("PUT", URL); xhr.setRequestHeader("Accept", "application/json"); xhr.setRequestHeader("Content-Type", "application/json"); xhr.onreadystatechange = function () { if (this.readyState == 4) { //do something not relevant } }; xhr.send({ "cover": { "color": "pink" } }); }

aquí están las opciones: Opciones para la actualización de la portada de la tarjeta Trello

así es como se ve un JSON de una tarjeta Trello:

 { "id": "..." . . . "cover": { "idAttachment": null, "color": null, "idUploadedBackground": null, "size": "normal", "brightness": "dark", "idPlugin": null }, . . . }

y gracias.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Lo resolví, si alguien encuentra esto y quiere la respuesta, esta es:

 function uptadeCardCover(cardId,color,size) { var url = "https://api.trello.com/1/cards/" + cardId + "?key=xxxxxx&token=xxxxxxxxx"; var xhr = new XMLHttpRequest(); xhr.open("PUT", URL); xhr.setRequestHeader("Accept", "application/json"); xhr.setRequestHeader("Content-Type", "application/json"); xhr.onreadystatechange = function () { if (this.readyState == 4 && this.status == 429) { // not relevant } }; xhr.send(JSON.stringify({ "cover": { "color": color, "size": size } })); }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!