live_help Notes

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

settings Params

Param name Description
roles_entity optional , nil allowed . Must be a Hash
roles_entity[role_id] required . Must be Fixnum

The role id. Must be unique in the scope of a given entity id and entity type.

roles_entity[entity_id] required . Must be Fixnum

The entity id.

roles_entity[expires_at] optional , nil allowed . Must be DateTime

The expires at.

roles_entity[entity_type] required . Must be String

The entity type.

comments powered by <span class='logo-disqus'>Disqus</span>
POST /v2/roles_entities
{
  "roles_entity": {
    "entity_id": "33",
    "entity_type": "Doorkeeper::Application",
    "role_id": "12"
  }
}
201
{
  "id": 57,
  "entity_id": 33,
  "entity_type": "Doorkeeper::Application",
  "created_at": "2017-03-06T15:20:31.892Z",
  "expires_at": null,
  "entity": {
    "id": 33,
    "name": "test basic staff oauth application",
    "description": null,
    "image": null,
    "website": null,
    "public": false,
    "scopes": [],
    "created_at": "2017-03-06T15:19:52.680Z",
    "updated_at": "2017-03-06T15:20:31.898Z",
    "owner": {},
    "rate_limit": 500
  },
  "role": {
    "id": 12,
    "name": "Moderator",
    "description": "Moderate topics, messages and versions on the forum"
  }
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"roles_entity":{"entity_id":"33","entity_type":"Doorkeeper::Application","role_id":"12"}}' "https://api.intra.42.fr/v2/roles_entities"

{
  "id": 57,
  "entity_id": 33,
  "entity_type": "Doorkeeper::Application",
  "created_at": "2017-03-06T15:20:31.892Z",
  "expires_at": null,
  "entity": {
    "id": 33,
    "name": "test basic staff oauth application",
    "description": null,
    "image": null,
    "website": null,
    "public": false,
    "scopes": [],
    "created_at": "2017-03-06T15:19:52.680Z",
    "updated_at": "2017-03-06T15:20:31.898Z",
    "owner": {},
    "rate_limit": 500
  },
  "role": {
    "id": 12,
    "name": "Moderator",
    "description": "Moderate topics, messages and versions on the forum"
  }
}
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 = {roles_entity: {entity_id: "33", entity_type: "Doorkeeper::Application", role_id: "12"}}
response = token.post("/v2/roles_entities", params: params)
response.status
# => 201
response.parsed
# => {"id"=>57, "entity_id"=>33, "entity_type"=>"Doorkeeper::Application", "created_at"=>"2017-03-06T15:20:31.892Z", "expires_at"=>nil, "entity"=>{"id"=>33, "name"=>"test basic staff oauth application", "description"=>nil, "image"=>nil, "website"=>nil, "public"=>false, "scopes"=>[], "created_at"=>"2017-03-06T15:19:52.680Z", "updated_at"=>"2017-03-06T15:20:31.898Z", "owner"=>{}, "rate_limit"=>500}, "role"=>{"id"=>12, "name"=>"Moderator", "description"=>"Moderate topics, messages and versions on the forum"}}