Question

I'm able to GET and POST data using Webclient, but I need to know how to PUT/Update data into the server..

MY code that I tryed with PUT methos in WebClient..

string serviceURL = REST_URI + servicePath;
Uri URI = new Uri(serviceURL);
WebClient webClient = new WebClient();
webClient.Headers["ContentType"] = "application/json";
webClient.Headers["Accept"] = "application/json";
webClient.UploadStringCompleted += this.updationCompleted;
webClient.UploadStringAsync(URI, "PUT", organizationDetails);



private void updationCompleted(object sender, UploadStringCompletedEventArgs e)
{
    try
    {
        MessageBox.Show("Success..");
        MessageBox.Show(e.Result);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);//i'm getting error here as check for inner exception..
    }

My Exception..

enter image description here Can anyone help me over this problem

My Inner Exception Message..

enter image description here

Was it helpful?

Solution

This is not a problem from your side:

The remote server returned an error: NotFound.

It looks like there is no such available method on server side or it doesn't accept PUT.

Make sure that you're using correct uri, http verb and content type.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top