API v2: add_attachment error: 412, no file uploaded

46 views
Skip to first unread message

Frismedia

unread,
Nov 22, 2016, 6:48:38 AM11/22/16
to CATS API
Hello,

Since today I'm not able to upload an attachment to the Catsone API, I always get the response code 412 (no file uploaded).

I've checked the file's existence, the file's (and folder's) permission and also tried to point directly to a public accessible file but nothing changed the outcome.

Do you have any idea what could be going wrong and what I could try to resolve this? Thank you.

Aaron Baluczynski

unread,
Nov 22, 2016, 10:03:00 AM11/22/16
to CATS API
Is this from a script that was working for you before?

I ran a test and add_attachment appears to be working normally.

The most common causes of this problem are file permission issues or sending the filename instead of the attachment content. I would suggest inspecting the actual POST data to see what you're sending to the API.

Aaron

Frismedia

unread,
Nov 22, 2016, 11:14:12 AM11/22/16
to CATS API
Our server was previously upgraded to php 5.6, because our hosting will no longer support lower version in the near feature and this seemed to be the problem. The Catsone PHP library (https://api.catsone.com/api/help.php?code=php5&file=library) uses '@filename' for adding files to curl requests, but this is deprecated (and seemingly not even working) since php 5.6. The file should now be added using the function curl_file_create.

This solved my problem. Thanks for your reply.
Reply all
Reply to author
Forward
0 new messages