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.

Rijwan AnsariRank #82 · 24.2K reputationPosted Mar 18, 2021, 2:58 AM EDT
Salman BegRank #284 · 8.8K reputationPosted Mar 17, 2021, 9:54 AM EDT
Riddhi ValechaRank #794 · 2.9K reputationPosted Mar 17, 2021, 10:43 AM EDT
Kiran MohantyRank #821 · 2.8K reputationPosted Mar 18, 2021, 5:02 AM EDT