Getting a 400 error on example

7 posts, 0 answers
  1. BitShift
    BitShift avatar
    174 posts
    Member since:
    Aug 2014

    Posted 21 May Link to this post

    I'm working through this example, although slightly changed a bit, but I am getting a http 400.
    I am trying to upload a json file.  The api path looks right when I debug but the request never makes it to the controller, however, I dont think its a routing issue as I would get a 404 error instead?

    https://docs.telerik.com/blazor-ui/components/upload/overview

     

     

  2. BitShift
    BitShift avatar
    174 posts
    Member since:
    Aug 2014

    Posted 21 May in reply to BitShift Link to this post

    Is this only for Client-side Blazor?
  3. BitShift
    BitShift avatar
    174 posts
    Member since:
    Aug 2014

    Posted 21 May Link to this post

    Ok, figured out what I was missing.  I thinkg I ran into this when I was building a Razorpages app.

    It was a routing issue after all.  Got to enable routing to api and other controllers, in Startup
    This isnt enabled by default in a new Blazor server-side app (not sure about Client side)

                app.UseEndpoints(endpoints =>
                {
                    endpoints.MapControllers();
                    endpoints.MapBlazorHub();
                    endpoints.MapFallbackToPage("/_Host");
                });

  4. BitShift
    BitShift avatar
    174 posts
    Member since:
    Aug 2014

    Posted 21 May in reply to BitShift Link to this post

    Oh, and its likely you will need to add this in Startup for ConfigureServices, if you havent already
                // web api
                services.AddControllers().AddNewtonsoftJson();
  5. Svetoslav Dimitrov
    Admin
    Svetoslav Dimitrov avatar
    116 posts

    Posted 22 May Link to this post

    Hello Randal,

    In our Create Project Wizard the endpoints.MapControllers(); should be enabled by default, you could try and create a new project and if it still missing you can open a Support ticket so we can further investigate.

    On the NewtonsoftJson framework, it is up to the application to define what third-party software products it will use.

    Regards,
    Svetoslav Dimitrov
    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.
  6. PH
    PH avatar
    17 posts
    Member since:
    Jul 2008

    Posted 31 May in reply to Svetoslav Dimitrov Link to this post

    Hitting the same problem.

    Can you include an Upload page in the Telerik Blazor Server template, then we can see how it works?

  7. Svetoslav Dimitrov
    Admin
    Svetoslav Dimitrov avatar
    116 posts

    Posted 01 Jun Link to this post

    Hello Peter,

    You can see how to setup the Upload component from our documentation, link here: https://docs.telerik.com/blazor-ui/components/upload/overview. In general, creating the Controller for the upload does not differ from the one you have for your database.

    You can also check our demos project that you have in the "demos" folder of your installation for an example.

    As attached file you can see a demo project which has the Upload set up.

    Regards,
    Svetoslav Dimitrov
    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