Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
The Request is Invalid Error from ASP.NET Web API
WhatsApp
Manoj Kalla
5y
21.7
k
0
0
25
Blog
Introduction
This post explains the 'The Request is Invalid' error from the ASP.NET Web API.
Error Reason:
Forgot to define routing.
Same method name.
Solved this error using Routing on the method level.
[HttpGet]
public
List<
string
> GetAllString()
{
return
new
List<
string
> {
"ABC"
,
"XYZ"
};
}
[HttpGet]
[Route(
"NumberList"
)]
public
List<
int
> GetAllNumbers()
{
return
new
List<
int
> { 122, 555 };
}
[HttpGet]
[Route(
"api/numberapi/NumberList"
)]
public
List<
int
> GetAllEvenNumber()
{
return
new
List<
int
> { 22, 44,66 };
}
Problem Solved
http://localhost:50297/numberlist
http://localhost:50297/api/numberapi/numberlist
NOTE
Some times the above solution will not fit or suit as per your current scenario. Please go through the following external links for solutions.
Other Links:
asp-net-webapi-newly-registered-route-says-that-request-is-invalid
overload-web-api-action-method-based-on-parameter-type
webapi-angularjs-the-request-is-invalid-error
web-api-request-invalid
Request Is Invalid Error From ASP.NET Web API
ASP.NET Web API
ASP.NET
Web API
People also reading
Membership not found