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
Riddhi Valecha
444
3.3k
412.6k
WebApi- The remote server returned an error: (405) Method Not Allowed.
Mar 16 2021 6:41 PM
Hello Team,
I need 1 help.
I have a web api for updating records.
I am trying to update records, but I am getting error.
I am sharing my code -
public
String LoadUpdateIDOFSerialNumber(
string
id)
{
string
resulat =
""
;
string
strUrl =
""
;
string
postdata =
""
;
try
{
strUrl = http:
//10.10.10.10/rs/fortpolio/aid/12345;
strUrl =
string
.Format(strUrl);
if
(strUrl !=
""
)
{
HttpWebRequest requestobjPost = WebRequest.Create(strUrl)
as
HttpWebRequest;
requestobjPost.Method =
"POST"
;
requestobjPost.ContentType =
"application/xml"
;
requestobjPost.Credentials =
new
NetworkCredential(
"user"
,
"user@123"
);
postdata =
"1"
;
using
(var streamWriter =
new
StreamWriter(requestobjPost.GetRequestStream()))
{
streamWriter.Write(postdata);
streamWriter.Flush();
}
var httpresponse = (HttpWebResponse)requestobjPost.GetResponse();
using
(StreamReader reader =
new
StreamReader(httpresponse.GetResponseStream()))
{
resulat = reader.ReadToEnd();
}
}
else
if
(strUrl ==
""
)
{
resulat =
"Bad Request"
;
}
}
catch
(Exception err) { err.Message.ToString(); }
return
resulat;
}
Error - The remote server returned an error: (405) Method Not Allowed.
Please help in solving this issue.
Reply
Answers (
4
)
CRUD Using JQuery and Ajax in ASP.NET Webform
asp.net core send two parameters to json procedure