-1

I want to Update data using webclient UploadString method. The following code gives error saying,

The remote server returned an error: (405) Method Not Allowed.

var syncClient = new WebClient();
string URI = "https://test-khalid.herokuapp.com/v1/roles/de988992-4db8-4f75-884b-3dba893310e6";
syncClient.Headers.Add("authorization", "invalid-token");
Response.Write(syncClient.UploadString(URI, "PUT", "{\"title\":\"Shomaail Title 1\", \"role_type\":\"3\" }"));

I wrote the above code following this. Please let me know the answer?

Abhilash Ravindran C K
  • 1,818
  • 2
  • 13
  • 22
Shomaail
  • 493
  • 9
  • 30
  • 2
    The error is fairly self-explanatory, it's saying the server says that method is not allowed. – DavidG Mar 19 '18 at 13:13
  • Did you try just sending as `post`? And why are you adding an "invalid-token" as the autorization header? – Leandro Angelo Mar 19 '18 at 13:29
  • Invalid token does not matter, I tried sending as post it works. then i found out that I have to send it as PATCH according to the configuration of server – Shomaail Mar 21 '18 at 11:37

1 Answers1

0

Problem is solved using PATCH command instead of PUT. In the server PATCH is specified for update not PUT

Shomaail
  • 493
  • 9
  • 30