Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • seanrock 241 posts 462 karma points
    Jan 02, 2024 @ 11:09
    seanrock
    0

    UmbracoAuthorizedApiController unsupported media type

    Hi

    re: umbraco v12

    I've got a controller to handle some backoffice member actions. I'm using UmbracoAuthorizedApiController as the base class for my controller and a simple end point that has a guid as its only parameter.

    I'm calling the endpoint using $.ajax (post) from the angular controller but i'm getting an unsupported media error.

    I've tried replacing the simple guid parameter with a class with the guid as a property of that class as I've seen suggested in some other posts but no joy.

    Any ideas?

    Thanks.

  • Garðar Þorsteinsson 114 posts 535 karma points
    Jan 02, 2024 @ 11:54
    Garðar Þorsteinsson
    0

    Hi,

    You are probably missing [FromBody] attribute

    //[FromBody]: Indicates that a parameter should be deserialized from the request body, typically used in POST and PUT requests.
    //[FromQuery]: Indicates that a parameter should be taken from the request's query string.
    //[FromRoute]: Indicates that a parameter should be taken from the route data.
    //[FromForm]: Indicates that a parameter should be taken from the Form data.
    [HttpPost]
    [Produces("application/json")]
    [Route("items/{id:Int}")]
    public async Task<ActionResult<IEnumerable<string>>> GetItems([FromBody] ApiRequest req)
    {
        return Ok();
    }
    
  • seanrock 241 posts 462 karma points
    Jan 02, 2024 @ 13:24
    seanrock
    0

    Hi

    Actually I did have that but I changed stuff around and it started working, i probably mispelled something :D

    Thanks.

Please Sign in or register to post replies

Write your reply to:

Draft