Http Error 415 when trying to remove an uploaded file

3 posts, 1 answers
  1. Mark Stevens
    Mark Stevens avatar
    11 posts
    Member since:
    Dec 2007

    Posted 02 Apr Link to this post

    I get the following error when attempting to remove an uploaded file. I'm using the example code from the Upload Overview Document https://docs.telerik.com/blazor-ui/components/upload/overview?_ga=2.20672573.407168315.1585784320-1941347284.1557871324

     

    VS 2019 Output Window.

    Failed to load resource: the server responded with a status of 415 () [https://localhost:44326/api/upload/remove]

    Microsoft.AspNetCore.Routing.EndpointMiddleware: Information: Executed endpoint 'TestUpload.Controllers.UploadController.Remove (TestUpload)'
    Microsoft.AspNetCore.Hosting.Diagnostics: Information: Request finished in 69.8482ms 415 application/problem+json; charset=utf-8

     

    Browser Console.

    telerik-blazor.js:39 POST https://localhost:44326/api/upload/remove 415
    value @ telerik-blazor.js:39
    value @ telerik-blazor.js:39
    value @ telerik-blazor.js:39
    value @ telerik-blazor.js:39
    value @ telerik-blazor.js:39
    u @ telerik-blazor.js:1
    (anonymous) @ blazor.server.js:8
    beginInvokeJSFromDotNet @ blazor.server.js:8
    (anonymous) @ blazor.server.js:1
    e.invokeClientMethod @ blazor.server.js:1
    e.processIncomingData @ blazor.server.js:1
    connection.onreceive @ blazor.server.js:1
    i.onmessage @ blazor.server.js:1

     

  2. Answer
    Mark Stevens
    Mark Stevens avatar
    11 posts
    Member since:
    Dec 2007

    Posted 02 Apr in reply to Mark Stevens Link to this post

    I added the [FromForm] attribute to the Remove method of the API and it's working now.

     

         public ActionResult Remove([FromForm] string[] files)

  3. Marin Bratanov
    Admin
    Marin Bratanov avatar
    5314 posts

    Posted 03 Apr Link to this post

    Thank you for sharing your solution with the community, Mark. I have marked it as the answer to this thread.

    It is a bit odd that the docs wouldn't work immediately, but there can be many specifics around the API endpoints an app can have and the Remove request is, ultimately, a form field in the POST query that contains a string.

     

    Regards,
    Marin Bratanov
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top