AnsweredAssumed Answered

Submit Assignment via API

Question asked by Douglas Tan on Sep 21, 2016
Latest reply on Dec 17, 2017 by Stuart Ryan


I followed the documentation here to submit a file ...

Uploading Files - Canvas LMS REST API Documentation

 

The end result is a file added to the user's personal file space, and I got back a file id. I can preview the file and I can download this file.

 

Then I want to use this file as assignment submission for the same user, which is done by this Canvas API.

Submissions - Canvas LMS REST API Documentation

 

But I am getting "No valid file ids given" error when calling that API. Can someone point me on the right path?

 

(code is in C#)

var url = $"https://{CanvasHost}/api/v1/courses/{CanvasCourseId}/assignments/{CanvasAssignmentId}/submissions?as_user_id={CanvasUserId}";
var formData = new Dictionary<string, string>
{
  {"comment[text_comment]", "submitted via FST"},
  {"submission[submission_type]", "online_upload"},
  {"submission[file_ids]", $"{fileSubmissionResult.CanvasFileId}"}
};

Outcomes