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
shashi kant
NA
15
3.6k
WebAPI giving GET method error when called in browser
Jul 14 2016 6:59 AM
hi!
I am currently following below link to learn WebAPI
Link:
http://www.c-sharpcorner.com/blogs/consuming-json-rest-or-restful-web-services-response-using-net-c-sharp-client1
I am getting error while calling POST method to Add Record.
Error message:
<Error><Message>The requested resource does not support http method 'GET'.</Message></Error>
POST method is :
[HttpPost]
public void AddEmployee(Employee employee)
{
//int maxId = listEmp.Max(e => e.ID);
//employee.ID = maxId + 1;
//listEmp.Add(employee);
SqlConnection myConnection = new SqlConnection();
myConnection.ConnectionString = @"Server=192.168.200.26;Database=DBCompany;User ID=xyz;Password=1234;";
//SqlCommand sqlCmd = new SqlCommand("INSERT INTO tblEmployee (EmployeeId,Name,ManagerId) Values (@EmployeeId,@Name,@ManagerId)", myConnection);
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.CommandType = CommandType.Text;
sqlCmd.CommandText = "INSERT INTO tblEmployee (EmployeeId,Name,ManagerId) Values (@EmployeeId,@Name,@ManagerId)";
sqlCmd.Connection = myConnection;
sqlCmd.Parameters.AddWithValue("@EmployeeId", employee.EmployeeId);
sqlCmd.Parameters.AddWithValue("@Name", employee.Name);
sqlCmd.Parameters.AddWithValue("@ManagerId", employee.ManagerId);
myConnection.Open();
int rowInserted = sqlCmd.ExecuteNonQuery();
myConnection.Close();
}
please tell me what is the right way of consuming this WEBAPI.
Reply
Answers (
5
)
how to view runtime show from report viewer to pdf in c#.net
How to develop window base Application in DOTNET core 1.0