AnsweredAssumed Answered

using PUT method to update a user in C#

Question asked by Jerry A Natarajan on Sep 13, 2015
Latest reply on Aug 19, 2016 by cesbrandt

hello all,

 

I am new to Canvas and I am trying to update an existing user in Canvas using REST API. I am able to use POST to create a user successfully.

But when I use PUT, the message returns 'OK' but nothing happens in Canvas. Below is the code I use

 

                var putData = new List<KeyValuePair<string, string>>();

                putData.Add(new KeyValuePair<string, string>("user[name]", "Bruce Thomas Wayne"));

                putData.Add(new KeyValuePair<string, string>("user[shortname]", "BAT"));

                HttpContent PUTcontent = new FormUrlEncodedContent(putData);

                using (HttpResponseMessage PUTresponse = client.PutAsJsonAsync("/api/v1/users/8?access_token=MYTOKEN", PUTcontent).Result)

                    if (PUTresponse.IsSuccessStatusCode)

                    {

                        Console.WriteLine("Success");

                    }

 

the PUTresponse resturns OK. Am I missing some key variable? Please do correct me if I am doing something ridiculous.

 

Thanks all in advance

Outcomes