Anyone tried to alter the announcement author via the discussion topic API?

don_bryn
Community Champion

I copy courses from sandboxes every semester and I use a batch of date-specific announcements every time.   Reminders like:  "Don't forget your papers are due by Friday night" and such.

It really bothers me that all the copied announcements look like I didn't make them because my authorship is stripped when the course is copied.

Since I'm working on this google doc to batch edit the announcement dates (which is pretty much done, BTW), I thought maybe I could update the author on each announcement as well.   I logged the input from an announcement and there is an author object, so I have created the same object going back but it doesn't seem to update.

Has anyone tried this before?  Should I keep trying or is it something that Canvas blocks on the incoming PUT?

The discussion post object as it comes in:

{
"id":151151,
"title":"Test Announcement",
"last_reply_at":"2017-11-14T21:10:31Z",
"delayed_post_at":"2018-01-07T13:00:00Z",
"posted_at":"2017-11-14T21:10:31Z",
"assignment_id":null,
"root_topic_id":null,
"position":32,
"podcast_has_student_posts":false,
"discussion_type":"side_comment",
"lock_at":null,
"allow_rating":false,
"only_graders_can_rate":false,
"sort_by_rating":false,
"user_name":"Donald Bryn",
"discussion_subentry_count":0,
"permissions":{"attach":true,"update":true,"reply":true,"delete":true},"
require_initial_post":null,
"user_can_see_posts":true,
"podcast_url":null,
"read_state":"read",
"unread_count":0,
"subscribed":false,
"topic_children":[],
"attachments":[],
"published":true,
"can_unpublish":false,
"locked":true,
"can_lock":true,
"comments_disabled":true,
"author":{
         "id":5054,
         "display_name":"Donald Bryn",
         "avatar_image_url":"https://scf.instructure.com/images/thumbnails/2936451/<removed>",
         "html_url":"https://scf.instructure.com/courses/20565/users/5054"

         },
"html_url":"https://scf.instructure.com/courses/20565/discussion_topics/151151",
"url":"https://scf.instructure.com/courses/20565/discussion_topics/151151",
"pinned":false,
"group_category_id":null,
"can_group":false,
"locked_for_user":false,
"message":"\u003cp style=\"font-size: 8pt; margin-top: -3px; margin-bottom: 3px;\"\u003eSession 1\u003c/p\u003e\r\n\u003cp\u003etest\u003c/p\u003e\u003cscript src=\"https://instructure-uploads.s3.amazonaws.com/account_21940000000000001/attachments/1625201/scf-app.j...\"\u003e\u003c/script\u003e",
"subscription_hold":"topic_is_announcement"
}

These are my parameters going out:

{
:id=148633.0,

author={
         avatar_image_url=https://scf.instructure.com/images/thumbnails/2936451/<removed>,
         html_url=https://scf.instructure.com/courses/20565/users/5054,
         id=5054.0,
         display_name=Donald Bryn
         },
:course_id=20565,
type=discussion,
delayed_post_at=2018-01-08T13:00:00Z
}

The delayed_post_at, ID, course_id, and type appear to function, but not the author.  It could just be something I'm not getting about formatting the object correctly.   I'm really just a hack at this.   But it looks like the format changes from incoming to outgoing are the same for delayed_post-at and author.

And I did try also sending the user_name, but didn't make a difference.

0 Likes