live_help Notes

assignment This action requires one of theses roles: Advanced tutor

settings Params

Param name Description
user_id optional . Must be String

The user id or slug

campus_user optional , nil allowed . Must be a Hash
campus_user[campus_id] optional , nil allowed . Must be Fixnum

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

campus_user[user_id] optional , nil allowed . Must be Fixnum

The user id.

campus_user[end_at] optional , nil allowed . Must be String

The end at.

campus_user[begin_at] optional , nil allowed . Must be String

The begin at.

campus_user[is_primary] optional , nil allowed . Must be one of: true, false.

Is it is primary ? Default to false.

comments powered by <span class='logo-disqus'>Disqus</span>
POST /v2/campus_users
{
  "campus_user": {
    "campus_id": "6",
    "user_id": "1"
  }
}
201
{
  "id": 75,
  "user_id": 1,
  "campus_id": 6,
  "is_primary": false
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"campus_user":{"campus_id":"6","user_id":"1"}}' "https://api.intra.42.fr/v2/campus_users"

{
  "id": 75,
  "user_id": 1,
  "campus_id": 6,
  "is_primary": false
}
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 = {campus_user: {campus_id: "6", user_id: "1"}}
response = token.post("/v2/campus_users", params: params)
response.status
# => 201
response.parsed
# => {"id"=>75, "user_id"=>1, "campus_id"=>6, "is_primary"=>false}