live_help Notes

assignment This action requires one of theses roles: Advanced tutor, Advanced staff

settings Params

Param name Description
role optional , nil allowed . Must be a Hash
role[name] optional , nil allowed . Must be String

The name. Must be unique.

role[description] required . Must be String

The description.

comments powered by <span class='logo-disqus'>Disqus</span>
POST /v2/roles
{
  "role": {
    "description": "Synchronised uniform parallelism",
    "name": "astronomer"
  }
}
201
{
  "id": 18,
  "name": "astronomer",
  "description": "Synchronised uniform parallelism"
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"role":{"description":"Synchronised uniform parallelism","name":"astronomer"}}' "https://api.intra.42.fr/v2/roles"

{
  "id": 18,
  "name": "astronomer",
  "description": "Synchronised uniform parallelism"
}
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 = {role: {description: "Synchronised uniform parallelism", name: "astronomer"}}
response = token.post("/v2/roles", params: params)
response.status
# => 201
response.parsed
# => {"id"=>18, "name"=>"astronomer", "description"=>"Synchronised uniform parallelism"}