thomas_bishop
Community Explorer

API POST Global Announcement to Specific Roles using Postman

Jump to solution

I am having trouble formatting a value array in Postman to post a Global Announcement to specific roles using the "account_notification_roles" as referenced in the Create a Global Announcement API. The documentation doesn't give much of an example and I've tried several ways to enter both the key and the value into the Postman Params tab. It either posts the announcement to everybody and doesn't pick up on the roles, or it generates an error. Here is a screen shot from Postman of my latest attempt. Each time it creates an announcement, the "role_ids" and "roles" response come back empty. Does anyone know the right combination/syntax that will work in this case? Thanks in advance.
Postman-GlobalAnnouncement-roles.PNG

Edit: I was able to upload the screen shot.

0 Likes
1 Solution
jerry_nguyen
Community Contributor

@thomas_bishop 

This is how you set it with Postman. If you want to add more roles you will need to add another account_notification_roles[] key to the list of params.

PostAnnouncement_Postman.JPG

Alternatively, you can use @James 's JSON and put it under "Body" -> "Raw" and change type from Text to JSON

PostAnnouncement_RawJSON.JPG

In your future posts, I would suggest you insert your image directly by uploading it from your computer rather than embedding a link from google drive

 

View solution in original post

3 Replies
James
Community Champion

@thomas_bishop 

Your screenshot didn't come through, so I cannot tell what you're doing wrong. I'll have to suggest the proper way to do it. I don't use Postman for my REST client, but there's nothing here that is specific to the client, it's about properly forming the request.

account_notification_roles[] is an array of strings. The [] at the end allows for repetition in case you want to send it to more than one role. If you leave off the [], then it will only keep one of them.

  • account_notification_roles[]=StudentEnrollment
  • account_notification_roles[]=TeacherEnrollment
  • account_notification_roles[]=Help Desk

"Help Desk" is a custom account role that we have created. You do not have to use one of the built-in roles. Looking at the source code, you can also use the role IDs.

If you want to use JSON, then you would make it an array of strings. Here is a complete working example in JSON

{
  "account_notification": {
    "subject": "Test Announcement, ignore",
    "message": "This is a test announcement, ignore it",
    "start_at": "2021-07-21T06:00:00Z",
    "end_at": "2021-07-22T06:00:00Z"
  },
  "account_notification_roles": [
    "TeacherEnrollment",
    "StudentEnrollment",
    "Help Desk"
  ]
}

 

jerry_nguyen
Community Contributor

@thomas_bishop 

This is how you set it with Postman. If you want to add more roles you will need to add another account_notification_roles[] key to the list of params.

PostAnnouncement_Postman.JPG

Alternatively, you can use @James 's JSON and put it under "Body" -> "Raw" and change type from Text to JSON

PostAnnouncement_RawJSON.JPG

In your future posts, I would suggest you insert your image directly by uploading it from your computer rather than embedding a link from google drive

 

thomas_bishop
Community Explorer

Thank you Jerry and James. That configuration worked even though I thought I had tried that one early on. Much to learn about all this. Having a community to call upon is wonderful and greatly appreciated.