AnsweredAssumed Answered

Submit file to assignment via API

Question asked by Juan Londono on Dec 5, 2017
Latest reply on Dec 5, 2019 by Erik Elfgren


I'm trying to submit an assignment via the API using C#. I have the file uploaded to the user's folder and now I need to link the file (with id =28386) to the assignment (id=1855) but I get a status  code 400 : "Bad Request" because of "No valid file ids given". I think it's the same issue as in Submit Assignment via API 



This is my code:


Dictionary<string, string> vars = new Dictionary<string, string>();

vars.Add("comment[text_comment]", "My comments here");
vars.Add("submission[submission_type]", "online_upload");
vars.Add("submission[file_ids][]", "28386"); // also tried without the '[]'

var p1Content = new FormUrlEncodedContent(vars.ToArray());
using (HttpResponseMessage response = await httpPOST(baseUrl, "/api/v1/courses/330/assignments/1855/submissions", accessToken, p1Content))



Many thanks in advanced for your help