Showing results for 
Show  only  | Search instead for 
Did you mean: 
Community Participant

Posting an assignment from a web application using Pandarus

I am a developer that is currently using the Pandarus (version 0.6.12) Ruby gem to assist with calls to the Canvas API from my web-based application built in Ruby on Rails.  I can successfully post an assignment from my site with the assignment's name, due date, maximum number of points for the assignment, and even that the assignment uses an external tool.  But I CAN'T seem to post it with the link to my application.  The call that I am using in Pandarus is "create_assignment".

First, I set up my client.

client = => 'https://' + canvas_instance_host_name_here + '/api', :token => access_token)

The following call WORKS with no link information posted:

client.create_assignment(course_id, assignment.description, {:assignment__submission_types__ => ['external_tool'],  :assignment__points_possible__ => assignment.max_score.to_i, :assignment__grading_type__ => 'points', :assignment__due_at__ => assignment.due_date_time.iso8601})

But when I try to insert the link information, the following call DOES NOT work:

client.create_assignment(course_id, assignment.description, {:assignment__submission_types__ => ['external_tool'], :assignment__external_tool_tag_attributes__ => {:url => "https://my_site_host_name_here/canvas/auth", :new_tab => true}, :assignment__points_possible__ => assignment.max_score.to_i, :assignment__grading_type__ => 'points', :assignment__due_at__ => assignment.due_date_time.iso8601})

The error is "ArgumentError (invalid number of elements (4 for 1..2))"

I'm betting that my syntax for the external tool tag attributes is wrong (the part I have in red).  What would be the correct syntax?

0 Kudos
3 Replies
Community Participant

A little update:

Upgrading to Pandarus 0.70 does not help.

Listing either ONE of the :assignment_external_tool_tag_attributes__ WORKS!

SOOO... my workaround is to first POST the assignment WITH the

:assignment__external_tool_tag_attributes__ => {:url => "https://my_site_host_name_here/canvas/auth"}


THEN record the id of the assignment, and then do a PUT on that assignment that only changes the "new_tab" parameter to true.

This works, but I'm still wondering why I can't post both parameters at the same time.

Community Coach
Community Coach

 @mrmike ,

Were you able to find an answer to your question? I am going to go ahead and mark this question as answered because there hasn't been any more activity in a while so I assume that you have the information that you need. If you still have a question about this or if you have information that you would like to share with the community, by all means, please do come back and leave a comment.  Also, if this question has been answered by one of the previous replies, please feel free to mark that answer as correct.



Community Participant

Thanks Robbie,

I wouldn't say that my workaround is the CORRECT answer, but I'm not

expecting anyone to get back to me on this.


On Tue, Mar 19, 2019 at 3:06 PM <>