Community

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
scottdennis
Community Team
Community Team

All things API

Have a question about the Canvas APIs? Have a cool API integration you'd be willing to share? If so, please post here.

Labels (1)
Tags (1)
271 Replies

I have gone through this thing painstakingly and still no joy.

First, it appears that you're uploading via URL. I am uploading a local file. I followed the instructions under "Uploading via POST at https://canvas.instructure.com/doc/api/file.file_uploads.html

I followed all three steps, and everything proceeded according to the instructions with one small difference. Where it says the response should be:

HTTP/1.1 301 Moved Permanently Location: https://<canvas>/api/v1/s3_success/1234?uuid=ABCDE I got:

HTTP/1.1 303 Location: https://<canvas>/api/v1/s3_success/1234?uuid=ABCDE

However, Step 3 worked fine, and I was even able to download the document via the URL provided in the response to #3.

Next, I extracted the ID from the response and did a PUT exactly as you indicated. I'm using curl, and here's my command:

curl -i 'https://auburn.instructure.com/api/v1/courses/AAAAAAA/assignments/BBBBBBBB/submissions/CCCCCCC' \

-X PUT \

-F 'comment[file_ids][]=9999' \

-H "Authorization: Bearer "

A comment appears in the student's submission that says "See attached files." just as though a file was attached. But no file is attached.

As an experiment, I put in a bogus file ID and got the same behavior. No error or anything, but the text comment shows up and nothing else. The most obvious explanation is that I'm somehow putting in the wrong file ID, but there's seemingly no way to mess that up. I'm using the "id" that comes out of Step 3 in Uploading via POST, the one labeled "1234" in the example:|

{|

"id":1234,"url":"...url to download the file...","content-type":"image/jpeg","display_name":"profile_pic.jpg","size":302185}

So, I'm clueless at this point.

Ok so this is going to be some painfully annoying thing but you are too close at this point to not see this through. Your calls appear to be all correct, this has to be some setting thing.

Authentication is good.

As far as local v url upload, we should be good because we know your file got to their server, as demonstrated by your ability to download from s3 url.

All we are attempting to do now is create a submission comment with a file that we know exists on their server.

Digging deep on these ideas:

1) Are you able to create a submission response with an attachment via the Canvas UI? Just to confirm you can perform this task in general.

2) Are you able to upload a file to the course? Instead of the submission comment url, see if you can just get a file on the course. To confirm you can add files to a course.

3) Go into the settings of the course and check the "File Storage:" setting to make sure you have enough. This one is a long shot, but you never know.

Good luck!!!

One more thing. You said you are seeing "See attached files"... I bet they are there.

Do a get on that submission with include[]=submission_comments

See if your file shows up there.

How big is the file you are uploading?

Another note - I noticed that when I submit a file through the UI, I see the "See attached file" with no file there. And then I refresh the screen and it shows up. Maybe do a hard cache clear refresh??? Reaching on that one too...

Not there.

And there's no attached file even after a refresh.

BTW, I don't know that it's relevant, but there's already one comment with an attachment (from using the web interface).

I'm working on your three suggestions...

1) Are you able to create a submission response with an attachment via the Canvas UI? Just to confirm you can perform this task in general.

Yes. I assume you mean via the normal web interface, and you're referring to submitting a comment file attachment. I don't think there's a way for me to submit on behalf of a student.

2) Are you able to upload a file to the course? Instead of the submission comment url, see if you can just get a file on the course. To confirm you can add files to a course.

Yes. It created a new folder called "unfiled" and the file was inside there.

3) Go into the settings of the course and check the "File Storage:" setting to make sure you have enough. This one is a long shot, but you never know.

2000MB

My file is 20K.

I am going to side by side bash script / js console this today.

I haven't experienced anything like this with their apI before!

I was able to successfully upload a submission comment via with CURL with an https URL. For some reason when I was trying to do it locally, I was getting some 403's when trying to upload my file to the s3, but you are not experiencing that.

2 things:

1) It is still odd that the submission comment says "see attachment", do a GET request on that submission with the param include[]=submission_comments and see if the JSON file has a url with your file.

2) Attempt to do this process with an https url to a file. Here is an easy one "https://s3.amazonaws.com/uifaces/faces/twitter/k/128.jpg "

Persistence and hard headed-ness will lead us to victory!

OK, finally had time to look into this.

1) It is still odd that the submission comment says "see attachment", do a GET request on that submission with the param include[]=submission_comments and see if the JSON file has a url with your file.

I had actually already done this at your request earlier. I did it again. There is no URL and no attachment associated with the comment.

2) Attempt to do this process with an https url to a file. Here is an easy one "https://s3.amazonaws.com/uifaces/faces/twitter/k/128.jpg "

I followed the instructions for a URL-based upload. Got the ID from it. Used curl as follows to PUT the file_id:

curl -i 'https://auburn.instructure.com/api/v1/courses/NNNNNN/assignments/OOOOOOO/submissions/PPPPPPP' \

-X PUT \

-F 'comment[file_ids][]=1234' \

-H "Authorization: Bearer "

It returned the submission, showing a new "See attached message" but with no attached file URL listed. Argh!