Search code examples
desire2learn

Getting a "405 - Method Not Allowed" error on a D2L post call that used to work


I have a mobile app that posts topics to our LMS (basically white board pictures) that was working for a few years now without a hitch. However, starting this fall semester, I am getting the error below. I asked our LMS people and they are unaware of why it is happening but did say we are on the continuous delivery model.

{
"type": "http://docs.valence.desire2learn.com/res/apiprop.html#method-not-allowed",
"title": "Method Not Allowed",
"status": 405,
"detail": "The POST method is not allowed on this resource.",
"allowed_methods": [
    "GET",
    "HEAD"
]
}

Here is the call and json that used to work:

/d2l/api/le/1.25/28866/content/modules/4923001/structure/

{"IsHidden": false, "IsLocked": false, "ShortTitle": "170905_080423", "Type": 1, 
      "DueDate": null, "Url": "170905_080423.jpg", 
      "StartDate": null, "TopicType": 1, "EndDate": null, "Title": "170905_080423"}

Solution

  • There appears to be a defect in the Brightspace LE v1.25 API contract on the /d2l/api/le/1.25/(orgunitId)/content/modules/(moduleId)/structure/ action route that suppresses the availability to use that route with POST (in order to add new child modules or topics to the content module structure).

    The workaround is to use an API contract between 1.22 and 1.24 if you need to use POST with this route (support for the base64 query parameter was added with 1.22, so picking that contract up to 1.24 may be pertinent; if you don't need that feature, you can use an earlier contract, but, if you were previously using a contract between 1.22 and 1.24 reverting to that contract for POST is likely the best workaround).