This is a migrated thread and some comments may be shown as answers.

Getting a 400 error on example

6 Answers 1338 Views
Upload
This is a migrated thread and some comments may be shown as answers.
BitShift
Top achievements
Rank 1
Veteran
BitShift asked on 21 May 2020, 09:08 PM

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

 

 

6 Answers, 1 is accepted

Sort by
0
BitShift
Top achievements
Rank 1
Veteran
answered on 21 May 2020, 09:26 PM
Is this only for Client-side Blazor?
0
BitShift
Top achievements
Rank 1
Veteran
answered on 21 May 2020, 09:58 PM

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");
            });

0
BitShift
Top achievements
Rank 1
Veteran
answered on 21 May 2020, 10:49 PM
Oh, and its likely you will need to add this in Startup for ConfigureServices, if you havent already
            // web api
            services.AddControllers().AddNewtonsoftJson();
0
Svetoslav Dimitrov
Telerik team
answered on 22 May 2020, 07:25 AM

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.
0
PH
Top achievements
Rank 2
answered on 31 May 2020, 06:46 PM

Hitting the same problem.

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

0
Svetoslav Dimitrov
Telerik team
answered on 01 Jun 2020, 12:26 PM

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.
AFS331
Top achievements
Rank 1
commented on 12 Jan 2024, 02:07 AM

Thank you very much, this example solved my problem
Tags
Upload
Asked by
BitShift
Top achievements
Rank 1
Veteran
Answers by
BitShift
Top achievements
Rank 1
Veteran
Svetoslav Dimitrov
Telerik team
PH
Top achievements
Rank 2
Share this question
or