Community

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
d_tan
Community Member

Submit Assignment via API

Jump to solution


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}"}

};

Labels (1)
1 Solution

Accepted Solutions

I did get it to work, my above code is almost correct, except you need to use this instead.

{"submission[file_ids][]", $"{fileSubmissionResult.CanvasFileId}"}

View solution in original post

5 Replies
juan_londono
New Member

Hi Douglas

Just wondering if you managed to resolve that problem - I'm having the same issue with no luck

Thanks

stuart_ryan
Community Coach
Community Coach

Hi  @d_tan ,

I am wondering how you went on this and if Peter's response above was able to help you out?

Cheers,

Stuart

I did get it to work, my above code is almost correct, except you need to use this instead.

{"submission[file_ids][]", $"{fileSubmissionResult.CanvasFileId}"}

Thanks so much for letting us know Douglas, and thank you to pklove for helping out!