创建一个部分

时间:2015-03-26 13:37:17

标签: c# json desire2learn

我正在创建一个应用程序,该应用程序将创建与用户创建的orgunitid相关联的部分。我正在使用c#。

但是,下面的代码不起作用。当我调试它时,尝试次数为0.如何正确发送请求并创建新部分?

private void ApiCreateSection(string host, ID2LUserContext userContext)
{
    string orgUnitId = textBoxOrgUnitId.Text;
    string sectionCreateRoute = "/d2l/api/lp/1.0/" + orgUnitId + "/sections/";
    var client = new RestClient(host);
    var valenceAuthenticator = new D2L.Extensibility.AuthSdk.Restsharp.ValenceAuthenticator(userContext);

    var requestCreateSection = new RestRequest(sectionCreateRoute, Method.POST);
    requestCreateSection.AddJsonBody(new 
    {
        Name = "Section Test1",
        Code = "123123",
        Description = new { Content = "Description", Type = "Html" }
    });
    valenceAuthenticator.Authenticate(client, requestCreateSection);
}

0 个答案:

没有答案