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

Import category groups through CSV via Canvas API

I'm trying to Create Groups in a Group Category through a CSV import using CANVAS API. 

I get a 200 OK response, in the canvas GUI all groups get added correctly as mentioned in the CSV file. But the students assigned under each group is not matching with the CSV file data.

I get the workflow state as queued and failed in the response.

CSV file has the following headers:-

name

canvas_user_id

user_id

login_id

sections

group_name

canvas_group_id

group_id

 

curl request:-

curl --location --request POST '<base canvas url>/api/v1/group_categories/:group_category_id/import' \
--header 'Authorization: Bearer  <token>\
--form 'attachment= <csv file>
 
I get the following as the response :-
{
"id": ###,
"context_id": ###,
"context_type": "GroupCategory",
"user_id": null,
"tag": "course_group_import",
"completion": 0.0,
"workflow_state": "queued",
"created_at": "####",
"updated_at": "####",
"message": null,
"url": "https://<canvas base url>/api/v1/progress/<progress_id>"
}
 

I tried using the progress_id from the above response to check the completion and status information about the asynchronous job, 

GET /api/v1/progress/:progress_id

I get the following as response:

{

   "id": ###,

    "context_id": ###,

    "context_type": "GroupCategory",

    "user_id": null,

    "tag": "course_group_import",

    "completion": 76.33587786259542,

    "workflow_state": "failed",

    "created_at": "###",

    "updated_at": "###",

    "message": "Unexpected error, ID: 89690000000109630",

    "url": "https://<canvas base url>/api/v1/progress/<progress_id>"

}

 

Has anyone encountered this issue? Need assistance in Creating Groups in a Group Category through a CSV import using CANVAS API. 

 

 

Labels (2)
0 Kudos
2 Replies
mzimmerman
Community Champion

What, specifically, are you trying to create?

When I look at the docs for the API you're calling, "Import category groups" (https://canvas.instructure.com/doc/api/group_categories.html#method.group_categories.import ) it looks like the API is for creating group categories, and says

For more information on the format that's expected here, please see the “Group Category CSV” section in the API docs.

The Group Category CSV section of the docs ( https://canvas.instructure.com/doc/api/file.sis_csv.html ) shows the header/fields in the group_category.csv as being

group_category_id,account_id,course_id,category_name,status

which is not what's in your CSV, as far as I can tell...

Where did you get the list of header fields that you used for your CSV file?