500 Internal Error for Crate File

javascript
files
curl
postman

#1

Hi. I can not upload the file through the service Files.

Headers:
Accept:application/json
Content-Type:application/json
Authorization:Bearer {MyToken}

Body:

{
	"file": "https://resize.yandex.net/mailservice?url=http%3A%2F%2Fimages.wbstatic.net%2Frsk%2F05_2018%2F23%2F1_03.jpg&proxy=yes&key=57515f3bf81ca5c24e21c6834e05e136"
}

Response:

{
    "errors": [
        {
            "status": 500,
            "title": "InternalError",
            "detail": "Cannot read property 'file' of undefined",
            "request_id": "6e29f0931ef30d2e"
        }
    ]
}

#2

Hey @vetal-frontend

You’ll need to set the Content-Type to multipart/form-data for file uploads. We don’t do remote file url uploads yet, so you’ll need to send your file via multipart.

Consider the following curl request:

curl -X POST https://api.moltin.com/v2/files \
     -H "Content-Type: multipart/form-data" \
     -H "Authorization: Bearer XXXX" \
     -d file=@/path/to/file \
     -d public=true 

I’ve made engineering aware of this who will patch the 500 error you’re receiving, you should get a validation warning to help others in the future.

I hope this helps :smile: