It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do I create a card with an attachment?

When trying to create a card using the API through the developers website with an attachment (see below)

var request = require("request");

var options = {
  method: 'POST',
  url: '',
  qs: {
    name: 'New Card',
    desc: 'this is the description',
    idList: '{my idList here}',
    fileSource: 'data:text/plain;name=ads.txt;base64,Z29vZ2xlLmNvbSwgcHViLTMyNDQzOTEzNDI4NDE4NjksIERJUkVDVCwgZjA4YzQ3ZmVjMDk0MmZhMA==',
    keepFromSource: 'all',
    key: '{my key here}',
    token: '{my token here}'

request(options, function (error, response, body) {
  if (error) throw new Error(error);



I get this as the response:

{"message":"Must provide either url or file""error":"VALIDATOR_INVALID_VALUE"}

But I am providing a "fileSource" so I'm not sure why it's telling me that I must provide either url or file when I am providing a file.  I can't seem to get around this.

Any help would be appreciated.



1 answer

0 votes
Iain Dooley Community Leader Mar 19, 2020

@Nir Modiano I've never been able to make "real" file uploads work with the API, I just assume it doesn't work. Maybe @bentley has some clues (I'll be listening closely)!

Even looking at whether or not attachments are files or links via the API seems to always return links -- as far as I can tell, attachments are always links, but somehow if you upload them via the Trello interface it flags them differently so you see the "PDF" or "DOC" icon, but via the API, I've only been able to create a link.

If I don't want this to look like it's a link, and instead want it to look like a file, I actually download it to Drive first then post the drive link to the file.

bentley Atlassian Team Mar 19, 2020

I think that I've only ever gotten a file to upload via API if I sent it as form-data.

I put together this Glitch project to play around with attachments awhile go. Taking a look at it might be helpful:

I'd also recommend asking questions about the API over here: There are other developers familiar with Trello that might be able to offer better advice.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Trello

Develop a new Habit during Lockdown

If you had to thrive a new habit during a lockdown, what would it be? Trello

1,520 views 13 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you