Connie DeCinko
Connie DeCinko

Reputation: 902

How to get just the file URL from the API

When I specify fields in my API request for most things I get the single value. However when I want just the URL of a file, I get everything, or more than I want. If I specify file.data.url in my filter I get this:

enter image description here

Upvotes: 2

Views: 3198

Answers (2)

Murtaza Mehmudji
Murtaza Mehmudji

Reputation: 319

Add fields as paramater to request ?fields=file.data.full_url

I would recommend full_url rather than url as url is relative.

Upvotes: 0

Binal Gajjar
Binal Gajjar

Reputation: 322

It is a known issue of the Directus. Currently, fields in the param are working with the column of the database table. The value of data variable is not the part of directus_files table.

Currently, you need to use the data object with all the values.

Upvotes: 1

Related Questions