每当我对"/d2l/api/le/(D2LVERSION: version)/(D2LID: orgUnitId)/ content /modules/(D2LID: moduleId)/ structure /“进行GET调用时,我在提供的moduleId结构中得到一个内容列表。但是,当我进行POST调用时,我得到一个Page Not Found错误。我用我想要添加内容的课程的id替换了orgUnitId,用我想要插入内容的模块的id替换了moduleId。下面是我发送的JSON代码块:
{"StartDate":null,
"Title":"My Test File",
"Type":1,
"ShortTitle":"MTF",
"TopicType":3,
"EndDate":null,
"IsHidden":false,
"Url":"http://somecollege.edu/",
"IsLocked":false}我不明白为什么我得到的页面没有发现错误的帖子,而不是在get上。有谁有什么想法吗?
发布于 2012-09-13 21:53:48
我们成功地在我们的测试服务器上发布了一个类似的链接主题。HTTP数据包(由wireshark捕获)如下所示:
POST /d2l/api/le/1.2/8083/content/modules/24980/structure/?x_t={timestamp}&x_a={app_id}&x_b={user_id}&x_d={user_sig}&x_c={app_sig} HTTP/1.1\r\n
Host: {test_hostname}\r\n
Content-Length: 186\r\n
Content-Type: application/json\r\n
Accept-Encoding: identity, deflate, compress, gzip\r\n
Accept: */*\r\n
\r\n
JavaScript Object Notation: application/json
Object
Member Key: "StartDate"
Null value
Member Key: "TopicType"
Number value: 3
Member Key: "ShortTitle"
String value: MTF
Member Key: "Title"
String value: My Test File
Member Key: "Url"
String value: http://www.desire2learn.com/
Member Key: "IsHidden"
False value
Member Key: "IsLocked"
False value
Member Key: "EndDate"
Null value
Member Key: "Type"
Number value: 1下面是作为发送的UTF-8字符串打印出来的JSON数据:
{"StartDate": null, "TopicType": 3, "ShortTitle": "MTF", "Title": "My Test File", "Url": "http://www.desire2learn.com/", "IsHidden": false, "IsLocked": false, "EndDate": null, "Type": 1}我看不出我们的JSON和您的JSON有什么显著的区别,所以问题很可能出在您实际发送的数据包上。404会表明您正在使用的路由并不完全正确(例如,在路由中的'structure‘后面应该有一个尾随斜杠)。
也有可能会遇到用户上下文调用的权限问题。请注意,用于查看课程内容(和结构)的角色权限与用于创建和管理课程内容的权限不同。您应该确保发出呼叫的用户上下文具有授予其适当权限的角色,不仅可以查看课程内容,还可以创建和管理内容。
如果这些建议都不起作用,那么我建议升级到下一个支持级别(使用D2L的问题跟踪器为Valence打开问题,或联系Valence支持电子邮件地址),以便他们可以更直接、更详细地来回帮助您。
https://stackoverflow.com/questions/12374182
复制相似问题