TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mohsin Arif
295
6k
137.8k
API show 400 Bad Request
Dec 31 2019 6:45 AM
hello guys
is there any issue in this code , because i m getting 400 bad request error,
public async Task
<
ActionResult
>
Index()
{
List
<
ModelHome
>
EmpInfo
=
new
List
<
ModelHome
>
();
using (var
client
=
new
HttpClient())
{
//Passing service base url
client.BaseAddress
=
new
Uri(Baseurl);
client.DefaultRequestHeaders.Clear();
//Define request data format
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token
);
client.DefaultRequestHeaders.Add("Access-Key", AccessKey);
//Sending request to find web api REST service resource GetAllEmployees using HttpClient
HttpResponseMessage
Res
=
await
client.GetAsync("api/Fee/GetDetail?
challan_number
=
4780415
&
branchCode
=
24
&
organizationUserId
=
445
");
//Checking the response is successful or not which is sent using HttpClient
if (Res.IsSuccessStatusCode)
{
//Storing the response details recieved from web api
var
EmpResponse
= Res.Content.ReadAsStringAsync().Result;
//Deserializing the response recieved from web api and storing into the Employee list
EmpInfo
=
JsonConvert
.DeserializeObject
<
List
<
ModelHome
>
>
(EmpResponse);
}
//returning the employee list to view
return View(EmpInfo);
}
}
Reply
Answers (
2
)
coding wise differenc ASP.Net web api Vs .Net core web api ?
need to performance tune by datareader