Using cURL and the Conversations API to create messages doesn't work

CarlThelen
Community Explorer

I have to create a bunch of messages (like, 1000 custom messages to specific students), and I'm trying to do it with the Canvas API. By way of testing, I'm trying to get it to just create a message to me based on my userID. When I put in the cURL command, it runs to completion, and gives me the created object (including ID number). But, the message doesn't show up in my inbox. 

Here's a sample from my MacOS Terminal command line:

cthelen@GoinC-MBP ~ % curl https://<our beta instance URL>/api/v1/conversations \
-X POST \
-H 'Authorization: Bearer <token>' \
-d 'recipients=172' \
-d 'event=add' \
-d 'subject=YetAnotherTest' \
-d 'visible=true' \
-d 'force_new=true' \
-d 'group_conversation=true' \
-d 'mode=sync' \
-d 'bulk_message=true' \
-d 'body=Four Score and Seven Years Ago'

[{"id":36384,"subject":"YetAnotherTest","workflow_state":"read","last_message":null,"last_message_at":null,"last_authored_message":"Four Score and Seven Years Ago","last_authored_message_at":"2025-02-18T21:45:31Z","message_count":1,"subscribed":true,"private":false,"starred":false,"properties":["last_author"],"audience":[],"audience_contexts":{"courses":{},"groups":{}},"avatar_url":"https://<our production URL>/images/thumbnails/262936/RAyQL6ZYCFHfpnqrt05PCWYXrOrua8u23oIfKmXy","participants":[{"id":172,"name":"Carl \"Crossbow\" Thelen","full_name":"Carl Thelen","pronouns":null}],"visible":false,"context_code":null}]

cthelen@GoinC-MBP ~ %

Note that every time it runs, the ID number increases by one, so it *looks* like it's working. Note also that it says visible:false even though I specify in the cURL command visible=true. Note also that when I use a cURL GET to retrieve the message based on the ID number, it returns

[{"attribute":"body","message":"blank"}]

which is the same as it returns if I give it a known bogus ID number.

Am I doing something obviously wrong? Does it work differently on production versus beta? Is there a way to use a URL to pull up a message by ID number (kinda like you can pull up a user profile by putting their ID number into the adress bar)? And, 'cause OF COURSE, I got this assignment with only 7 days to accomplish it....

Any help would be welcome.

Cheers!

0 Likes