Error with creating Asset

Hello everyone. I faced with error, when I created asset.
I post request on api/v2/file_asset to get uri, after what I try to make asset with many diferrent jsons like that
{
“name”: “videop4”,
“uri”: “/data/screenly_assets/8101e0c685455929ab31b0eb669ec821.tmp”,
“start_date”: “2026-08-24T14:15:22Z”,
“end_date”: “2026-08-24T14:15:22Z”,
“duration”: 1,
“mimetype”: “video/mp4”,
“is_enabled”: false
}, but everytime get this

{
“error”: “Invalid file path. Failed to add asset.”
}

there is an interesting situation with the “uri” field: if I change the first part, in particular “/” or remove “data”, an error appears:
{
“error”: “Invalid URL. Failed to add asset.”
}
But if I change some last part, somehow break it, then the error remains the same.

I would be very grateful for the help.

@Nicky, removing the / or even /data will certainly give you issues saying that the file path is invalid. Calling POST /api/v2/file_asset will give you a response similar to the following:

{
	"uri": "/data/screenly_assets/[random-hex].tmp",
	"ext": ".mp4"
}

Make sure not to tamper with the uri, as uploaded files get saved in /data, and later renamed when POST /api/v2/assets succeeds. Your request should look similar to the following:

{
  "ext": ".mp4",
  "name": "[preferred-filename].mp4",
  "uri": "/data/screenly_assets/[random-hex].tmp",
  "start_date": "2025-01-03T09:57:48.753Z",
  "end_date": "2026-01-03T09:57:48.753Z",
  "duration": 20,
  "mimetype": "video",
  "is_enabled": true,
  "is_processing": true,
  "nocache": false,
  "play_order": 0,
  "skip_asset_check": true
}

TL;DR: Do not modify the path/URI whenever possible.

I hope that answers the question. Please let me know if you need further help.

1 Like

@nicomiguelino , thanks for your help! But I still can’t post it :smile:

So, I created a file and get this uri: /data/screenly_assets/8101e0c685455929ab31b0eb669ec821.tmp

And as you told, formed this request:
{
“ext”: “.MP4”,
“name”: “myfirstVideo.mp4”,
“uri”: “/data/screenly_assets/8101e0c685455929ab31b0eb669ec821.tmp”,
“start_date”: “2025-01-03T09:57:48.753Z”,
“end_date”: “2026-01-03T09:57:48.753Z”,
“duration”: 10,
“mimetype”: “video”,
“is_enabled”: true,
“is_processing”: true,
“nocache”: false,
“play_order”: 0,
“skip_asset_check”: true
}

And still get this error 500:
{
“error”: “Invalid file path. Failed to add asset.”
}

Maybe, I’ve made some mistake again?

@Nicky, I initially tested the endpoints with images. Clearly, handling of video assets is quite different. I’m still trying to make the API calls work. I’ll let you know when I come up with something.

1 Like

@Nicky,

Here’s an update. (I hope it works.) :sparkles:

I revisited the source code and found out that the POST /api/v2/assets will likely give an error if duration is set to a non-zero value when creating video assets.

In the meantime, what you could do is do an API call to POST /api/v2/assets but use 0 for the duration.

That behavior is affecting the API user/developer experience. Thanks for bringing this up. I’ll let you know when I made minor and patch changes to that endpoint.

Please let me know if you’re still having the issue.

1 Like

@nicomiguelino , thank you very mach!