Trello REST API POST permissions broken?

Hi people,

I can use the API project key and user token to view cards in trello REST API. Up until recently, I could also POST files onto those trello cards as attachments using the REST API. All of a sudden, now I can’t POST. Is the API partially broken at the moment or has something changed with API access?

The error I now receive (in myJson.response) is:

<Response [404]>

and in the myJson.text:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST //1/cards/{card ID deleted}/attachments</pre>
</body>
</html>

I recreated my token and ensured it was marked for read and write permissions. From the 404 error, it appears to be a permissions issue, but the card being written to is newly created and using the same account tied to that token.

Any other ideas?

Thanks

Regards

Mark

Here is my python function:

def addCardAttachment(trelloKey, trelloToken, filePath, cardId):
  import requests
  import json

  url = f"https://api.trello.com//1/cards/{cardId}/attachments"

  headers = {
    "Accept": "application/json"
  }

  query = {
    'key' : trelloKey,
    'token' : trelloToken,
  }

  files = {
    'file': open(filePath, 'rb'),
  }

  response = requests.request(
    "POST",
    url,
    headers=headers,
    params=query,
    files=files
  )

  myJson = json.loads(response.text)
  return myJson

Based on that error, it looks like you’re trying to POST to //1/cards/ instead of /1/cards/. Does updating that make a difference?

@bcook Brilliant! I feel really stupid now. I’m not sure when that extra / crept in, but in the hours of trying to get this to work, I overlooked the obvious. Thanks very much!