AnsweredAssumed Answered

Posting an assignment from a web application using Pandarus

Question asked by Michael Eiseman on Oct 4, 2018
Latest reply on Mar 19, 2019 by Michael Eiseman

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?