Skip to content

Delivery API - Getting media by path returns 500 error #20810

@lauraneto

Description

@lauraneto

Which Umbraco version are you using?

17.0.0-rc2

Bug summary

Found this while working on another feature. I haven't checked which versions are affected by this.
Attempting to call the /umbraco/delivery/api/v2/media/item/{path} with a valid path returns a 500 error with the following exception:

System.InvalidOperationException: Wasn't able to get an UmbracoContext
   at Umbraco.Extensions.UmbracoContextAccessorExtensions.GetRequiredUmbracoContext(IUmbracoContextAccessor umbracoContextAccessor)
   at Umbraco.Cms.Core.Routing.UrlProvider.GetMediaUrl(IPublishedContent content, UrlMode mode, String culture, String propertyAlias, Uri current)
   at Umbraco.Cms.Core.DeliveryApi.ApiMediaUrlProvider.GetUrl(IPublishedContent media)
   at Umbraco.Cms.Core.DeliveryApi.ApiMediaBuilder.Build(IPublishedContent media)
   at Umbraco.Cms.Infrastructure.DeliveryApi.ApiMediaWithCropsBuilderBase`1.Build(MediaWithCrops media)
   at Umbraco.Cms.Infrastructure.DeliveryApi.ApiMediaWithCropsBuilderBase`1.Build(IPublishedContent media)
...

Specifics

No response

Steps to reproduce

  1. Create a new project.
  2. Enable the Delivery API and Media, with public access enabled.
  "Umbraco": {
    "CMS": {
      ...
      "DeliveryApi": {
        "Enabled": true,
        "PublicAccess": true,
        "Media": {
          "Enabled": true,
          "PublicAccess": true
        }
      }
  1. Upload an image to the media section.
  2. Try to retrieve the image using the /umbraco/delivery/api/v2/media/item/{path} endpoint.

Expected result / actual result

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions