Looking at the syntax of your curl command, I think you have a couple of typos.
I just tested this call against my test environment, and it is working properly.
Here is my command that worked:
Proper Format of cURL Command
curl https://mysite.test.instructure.com/api/v1/courses/1234/assignments/5678/submissions/update_grades
-X POST
-F "grade_data[110][posted_grade]=88"
-F "grade_data[109][posted_grade]=95"
-H "Authorization: Bearer myprivatesecuritytoken"
API Results
After running this command, I looked at the gradebook in Canvas and confirmed that the two grades had been updated.
Next I inspected the result received from the call, here it is:
{
"id" : 6974,
"context_id" : 1040,
"context_type" : "Course",
"user_id" : null,
"tag" : "submi
ssions_update",
"completion" : null,
"workflow_state" : "queued",
"created_at" : "2016-06
-30T12:50:59Z",
"updated_at" : "2016-06-30T12:50:59Z",
"message" : null,
"url" : "https://mysite.test.instructure.com/api/v1/progress/6974"
}
Important Note: this result is simply telling you that your request was successfully received. "workflow_state" suggests that this is running as a workflow, similar to a SIS import, and that is is not returning a synchronous result. If you don't understand what this means, post another question and I'll explain.
You should also make note of the "url" that was sent back, which is an API call. The "progress" value of the url strongly suggests that this API call will give you the status of the workflow.
Properly Check the Status
It sounds as though you are looking at "user_id": null and deciding the request has failed.
However, you make the API call given in the results to to get the actual status (see "url" value in results above in bold). Here is the curl command to get the results, the API url is found in the results of the previous API call, shown in bold above:
curl https://mysite.test.instructure.com/api/v1/progress/6974
-H "Authorization: Bearer myprivatesecuritytoken"
Here is the result I received:
{
"id": 6974,
"context_id": 1040,
"context_type": "Course",
"user_id": null,
"tag": "submissions_update",
"completion": 100.0,
"workflow_state": "completed",
"created_at": "2016-06-30T12:50:59Z",
"updated_at": "2016-06-30T12:51:01Z",
"message": null,
"url": "https://mysite.test.instructure.com/api/v1/progress/6974"
}
You will make this call as many times as needed until "completion" give you back 100.0, or a failure code.
See the definition of the Progress API for details on expected values: Progress - Canvas LMS REST API Documentation
Notice in this result completion is 100%.
Testing a Failure Scenario
So the next step is to understand what to expect if the API call to update the grades fails.
Using the first curl command above, I passed invalid student_id values.
The result I got back was essentially the same result, telling me that the workflow_state was queued.
This demonstrates why you have to make the second API call to get the status of the job.
I was not able to determine that the workflow had failed until I made the second API call.
Here is the result I get from the second API call when the job fails:
{
"id" : 6975,
"context_id" : 1040,
"context_type" : "Course",
"user_id" : null,
"tag" : "submissions_update",
"completion" : null,
"workflow_state" : "failed",
"created_at" : "2016-06 -30T12:59:44Z",
"updated_at" : "2016-06-30T12:59:45Z",
"message" : "Couldn't find User(s) with API ids '0'",
"url" : "https://mysite.test.instructure.com/api/v1/progress/6975"
}
Notice this result clearly tells me that the API request has failed.
Follow these steps:
- correct the syntax of your curl command and make sure you understand the parameters and can get the expected results
- dig back into your code and determine if you still have a problem
I hope this helps.