Update Course Name with API in c#

Jump to solution
Community Explorer

I am having a issue trying to update a course name in c#. I perform the PUT and I get a 200 OK back but the name does not change.

Here are the details:

URL: /api/v1/courses/1724

Content: "{\"id\":1724,\"name\":\"2 Test - 1 Test - Competing in and with China\"}":  - this is the data that is used to initialize the StringContent Object

   string jsonData = JsonConvert.SerializeObject(data);    HttpContent content = new StringContent(jsonData);

    var response = (HttpResponseMessage)Task.Run(async () => await client.PutAsync(urlCommandcontent)).Result;

This returns a 'StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1' but the data is never updated

Does anyone have any ideas??

Labels (1)
1 Solution
Community Champion

 @aday ,


I can't help with C#, but your parameters are improperly formed. Canvas is accepting the call, ignoring anything it doesn't recognize (which is the entire payload), saying "OK" to the empty list of changes, and not making any changes.

The Update a course endpoint requires that all of the parameters be wrapped inside the course property.

ID is not supported as a parameter, but it is specified in the path portion of the URL. Do not include it in your content as it will be ignored.

The course name is course[name] as a query parameter. In JSON, it would look like: { "course" : { "name" : "2 Test - 1 Test - Competing in and with China" } }

View solution in original post