Example making a submission to an assignment using the API?
Hi all,
I'm trying to use the Brighspace API to make submissions to assignments from an instructional programming environment (IPE). The students submits their work in the IPE, then the IPE submits the names of the files submitted to Brightspace.
I'm using this API:
POST /d2l/api/le/(version)/(orgUnitId)/dropbox/folders/(folderId)/submissions/mysubmissions/
but I'm getting a 400 status code with the detail, "Request has missing or invalid parameters."
The documentation says "The post’s multipart/mixed body should contain a JSON part encoding the submission’s descriptive comments in RichText, followed by the submission file’s data (the action requires a submission to include a file, not just a description)." I've taken a stab at following this but no luck so far.
Is there an example anywhere that shows what the POST body needs to contain?
Thank you,
—Jon
Answers
-
Hi Jonathan,
Thank you for reaching out to the D2L Brightspace Community!
Based on the API call you have shared, it appears that the issue may stem from certain limitations in Apitesttool's support for file uploads. We recommend utilizing Postman to execute this POST request for a smoother experience.
Should you require further assistance, feel free to connect with our developer community platform (url below) or submit a support ticket.
Thanks,
Unaib Nazir
Technical Support Analyst
D2L Corporation
-
Hi Unaib,
Thank you for your response. I am not using Apitesttool, I am testing directly with my application. I may give Postman a try. I have since gone beyond the 400 error, now I am getting a 500 response:
{"type":"about:blank","title":"Internal Server Error","status":500}
According to the documentation, this means that "Submitted comments are too large." But the entire POST body is 338 bytes, so that doesn't seem right. In case you can see something, here is the body of my post:
--78d705f9-6be1-4504-a447-7240ae816ebd
Content-Type: application/json{"Text":"Submitted from CodeWork","Html":"<p>Submitted from CodeWork</p>"}
--78d705f9-6be1-4504-a447-7240ae816ebd
Content-Type: text/plaingmail.com/jpmunson/OCT/submissions/WCOXBRSQ/Test121/jpmunson/HelloWorld.java
--78d705f9-6be1-4504-a447-7240ae816ebd--Content-Type header is set to "multipart/mixed; boundary=78d705f9-6be1-4504-a447-7240ae816ebd"
Content-Length header is set to 338
Thank you for any assistance you can give me on this.
—Jon
-
Got through the 500 error—the problem was that I was missing a Content-Disposition line. I would have loved for that to be reflected in the error message, or at least for the API documentation not to say that the problem was that submitted comments are too large. But this documentation was extremely helpful:
https://docs.valence.desire2learn.com/basic/fileupload.html