live_help Notes

assignment This action requires one of theses roles: Advanced tutor

settings Params

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

The group id. Must be unique in the scope of a given user.

groups_user[user_id] required . Must be Fixnum

The user id.

POST /v2/groups_users
{
  "groups_user": {
    "group_id": "3",
    "user_id": "9"
  }
}
201
{
  "id": 5,
  "user_id": 9,
  "group_id": 3,
  "created_at": "2017-11-22T13:43:41.210Z",
  "updated_at": "2017-11-22T13:43:41.210Z"
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"groups_user":{"group_id":"3","user_id":"9"}}' "https://api.intra.42.fr/v2/groups_users"

{
  "id": 5,
  "user_id": 9,
  "group_id": 3,
  "created_at": "2017-11-22T13:43:41.210Z",
  "updated_at": "2017-11-22T13:43:41.210Z"
}
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 = {groups_user: {group_id: "3", user_id: "9"}}
response = token.post("/v2/groups_users", params: params)
response.status
# => 201
response.parsed
# => {"id"=>5, "user_id"=>9, "group_id"=>3, "created_at"=>"2017-11-22T13:43:41.210Z", "updated_at"=>"2017-11-22T13:43:41.210Z"}