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

cursus_user optional , nil allowed . Must be a Hash
cursus_user[cursus_id] required . Must be Fixnum

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

cursus_user[user_id] required . Must be Fixnum

The user id.

cursus_user[end_at] optional , nil allowed . Must be DateTime

The end at.

cursus_user[begin_at] required . Must be DateTime

The begin at.

comments powered by <span class='logo-disqus'>Disqus</span>
POST /v2/cursus_users
{
  "cursus_user": {
    "begin_at": "2016-11-06 15:19:52 UTC",
    "cursus_id": "2",
    "end_at": "2017-07-06 15:19:52 UTC",
    "user_id": "3"
  }
}
201
{
  "id": 72,
  "begin_at": "2016-11-06T15:19:52.000Z",
  "end_at": "2017-07-06T15:19:52.000Z",
  "grade": null,
  "level": 0.0,
  "skills": [],
  "cursus_id": 2,
  "user": {
    "id": 3,
    "login": "gargamel",
    "url": "https://api.intra.42.fr/v2/users/gargamel"
  },
  "cursus": {
    "id": 2,
    "created_at": "2017-03-06T14:58:44.047Z",
    "name": "42",
    "slug": "42"
  }
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"cursus_user":{"begin_at":"2016-11-06 15:19:52 UTC","cursus_id":"2","end_at":"2017-07-06 15:19:52 UTC","user_id":"3"}}' "https://api.intra.42.fr/v2/cursus_users"

{
  "id": 72,
  "begin_at": "2016-11-06T15:19:52.000Z",
  "end_at": "2017-07-06T15:19:52.000Z",
  "grade": null,
  "level": 0.0,
  "skills": [],
  "cursus_id": 2,
  "user": {
    "id": 3,
    "login": "gargamel",
    "url": "https://api.intra.42.fr/v2/users/gargamel"
  },
  "cursus": {
    "id": 2,
    "created_at": "2017-03-06T14:58:44.047Z",
    "name": "42",
    "slug": "42"
  }
}
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 = {cursus_user: {begin_at: "2016-11-06 15:19:52 UTC", cursus_id: "2", end_at: "2017-07-06 15:19:52 UTC", user_id: "3"}}
response = token.post("/v2/cursus_users", params: params)
response.status
# => 201
response.parsed
# => {"id"=>72, "begin_at"=>"2016-11-06T15:19:52.000Z", "end_at"=>"2017-07-06T15:19:52.000Z", "grade"=>nil, "level"=>0.0, "skills"=>[], "cursus_id"=>2, "user"=>{"id"=>3, "login"=>"gargamel", "url"=>"https://api.intra.42.fr/v2/users/gargamel"}, "cursus"=>{"id"=>2, "created_at"=>"2017-03-06T14:58:44.047Z", "name"=>"42", "slug"=>"42"}}