desire2learn api adding content

谁都会走 提交于 2019-12-12 22:55:00

问题


Whenever I make a GET call to "/d2l/api/le/(D2LVERSION: version)/(D2LID: orgUnitId)/content/modules/(D2LID: moduleId)/structure/" I get a list of content in the provided moduleId structure. However, when I make a POST call I get a Page Not Found error. I've replaced the orgUnitId with the id of the course I want to add content to and replaced the moduleId with the id of the module I want to insert the content into. Here is the JSON block I'm sending:

{"StartDate":null,
"Title":"My Test File",
"Type":1,
"ShortTitle":"MTF",
"TopicType":3,
"EndDate":null,
"IsHidden":false,
"Url":"http://somecollege.edu/",
"IsLocked":false}

I don't understand why I get the page not found error on the post and not on the get. Anyone have any ideas?


回答1:


We were able to successfully post a similar link-topic on our test server. The HTTP packet (captured by wireshark) looks like this:

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

Here is what the JSON data looks like printed out as the UTF-8 string sent:

{"StartDate": null, "TopicType": 3, "ShortTitle": "MTF", "Title": "My Test File", "Url": "http://www.desire2learn.com/", "IsHidden": false, "IsLocked": false, "EndDate": null, "Type": 1}

I see no significant difference between our JSON and yours, so the problem likely lies with the packet that you're actually sending out. A 404 would suggest that the route you're using is not exactly as it should be (for example, there should be a trailing slash after 'structure' in the route).

It's also possible that you're running into a permissions issue for the user-context making the call. Notice that the role permissions for viewing course content (and structure) are different to the permissions for creating and managing course content. You should ensure that the user context making the call has a role that grants it the appropriate permissions for not only viewing course content, but creating and managing content as well.

If neither of these suggestions helps, then I suggest escalating to the next level of support (open an issue with D2L's issue tracker for Valence, or contact the Valence support email address) so they can help you out more directly and with more detail back and forth.



来源:https://stackoverflow.com/questions/12374182/desire2learn-api-adding-content

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!