POST /v2/announcements
Create an announcement
POST /v2/cursus/:cursus_id/announcements
Create an announcement for the given Cursus
live_help Notes
assignment
This action requires one of theses roles:
Community manager
settings Params
Param name | Description |
---|---|
cursus_id |
optional
. Must be String
The cursus id or slug |
announcement | optional , nil allowed . Must be a Hash |
announcement[cursus_ids] |
optional
, nil allowed
. Must be an array of Integer
The cursus ids. |
announcement[campus_ids] |
optional
, nil allowed
. Must be an array of Integer
The campus ids. |
announcement[author] |
required
. Must be String
The author. |
announcement[title] |
required
. Must be String
The title. |
announcement[text] |
required
. Must be String
The text. |
announcement[kind] |
optional
, nil allowed
. Must be String
The kind. |
announcement[expire_at] |
required
. Must be Fixnum
The expire at. . |
announcement[image] |
optional
, nil allowed
. Must be String
The image. |
Examples
POST /v2/announcements
{
"announcement": {
"author": "42partnerships",
"campus_ids": [
"1"
],
"cursus_ids": [
"1"
],
"expire_at": "2017-11-22 14:13:10 UTC",
"kind": "global",
"text": "42partnerships revient",
"title": "Partenariats écoles 2016"
}
}
201
{
"id": 5,
"author": "42partnerships",
"title": "Partenariats écoles 2016",
"text": "42partnerships revient",
"kind": "global",
"link": null,
"created_at": "2017-11-22T13:43:27.259Z",
"updated_at": "2017-11-22T13:43:27.259Z",
"expire_at": "2017-11-22T14:13:10.000Z"
}
curl -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"announcement":{"author":"42partnerships","campus_ids":["1"],"cursus_ids":["1"],"expire_at":"2017-11-22 14:13:10 UTC","kind":"global","text":"42partnerships revient","title":"Partenariats écoles 2016"}}' "https://api.intra.42.fr/v2/announcements"
{
"id": 5,
"author": "42partnerships",
"title": "Partenariats écoles 2016",
"text": "42partnerships revient",
"kind": "global",
"link": null,
"created_at": "2017-11-22T13:43:27.259Z",
"updated_at": "2017-11-22T13:43:27.259Z",
"expire_at": "2017-11-22T14:13:10.000Z"
}
require "oauth2"
UID = "Your application uid"
SECRET = "Your application secret"
client = OAuth2::Client.new(UID, SECRET, site: "https://api.intra.42.fr")
token = client.client_credentials.get_token
params = {announcement: {author: "42partnerships", campus_ids: ["1"], cursus_ids: ["1"], expire_at: "2017-11-22 14:13:10 UTC", kind: "global", text: "42partnerships revient", title: "Partenariats écoles 2016"}}
response = token.post("/v2/announcements", params: params)
response.status
# => 201
response.parsed
# => {"id"=>5, "author"=>"42partnerships", "title"=>"Partenariats écoles 2016", "text"=>"42partnerships revient", "kind"=>"global", "link"=>nil, "created_at"=>"2017-11-22T13:43:27.259Z", "updated_at"=>"2017-11-22T13:43:27.259Z", "expire_at"=>"2017-11-22T14:13:10.000Z"}