#Selecting 'url' from upload becomes null

10 messages · Page 1 of 1 (latest)

rose oasis
#

When I query an upload collection, in this case 'covers', I expect to get the URL back.
This works normally, unless I'm selecting the url field with a REST API Select.
https://payloadcms.com/docs/queries/select#rest-api

Basically, I query the document like this:
http://localhost:3000/cms/api/covers/6996e372fd561794164b28e8
I get the response

{
  "createdAt": "2026-02-19T10:18:26.920Z",
  "updatedAt": "2026-02-24T10:27:36.118Z",
  "url": "/cms/api/covers/file/20260113-001-KIT-MAIN-COV01jpg",
  "filename": "20260113-001-KIT-MAIN-COV01jpg",
  "id": "6996e372fd561794164b28e8"
  // ..etc
}

But when I query like this, selecting url:
http://localhost:3000/cms/api/covers/6996e372fd561794164b28e8?select[url]=true
I get the response:

{
  "url": null,
  "id": "6996e372fd561794164b28e8"
}

Why is this happening?

rose oasis
#
  • Selecting other fields next to url doesn't make a difference
  • This can be tested directly in the browser, it isn't a coding mistake on my part.
rose oasis
#

I still haven't found a solution to this problem.

rose oasis
#

According to ChatGPT, the problem is that url is a computed field which doesn't work with select at all.
Is the solution to not use select or is there a way to use select and still get the computed url field?

rose oasis
#

With some tiny changes I now instead query the filename which is not a computed field, and construct the URL from that.
It was a bit confusing because I am migrating from the GraphQL API to the Rest API. The GraphQL queries seem to resolve virutal fields just fine.

blissful dawnBOT
sleek cosmos
#

@rose oasis You need filename to calcualte the url, and that does also payload internally need.
So you need to do: ?select[url]=true&select[filename]=true
Then it has the data needed to show it.

rose oasis
#

Thank you for the confirmation, that's a bit less manual logic.