live_help Notes

assignment This action requires one of theses roles: Advanced tutor

settings Params

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

The name.

exam[begin_at] required . Must be DateTime

The begin at.

exam[end_at] required . Must be Fixnum

The end at. Beginning must be after ending.

exam[location] required . Must be String

The location.

exam[ip_range] required . Must be String

The ip range.

exam[visible] optional , nil allowed . Must be one of: true, false.

Is it visible ? Default to true.

exam[max_people] optional , nil allowed . Must be Fixnum

The max people.

exam[project_ids] optional , nil allowed . Must be an array of Integer

The project ids.

exam[campus_ids] optional , nil allowed . Must be an array of Integer

The campus ids.

comments powered by <span class='logo-disqus'>Disqus</span>
POST /v2/exams
{
  "exam": {
    "begin_at": "2017-11-25 13:43:10 UTC",
    "campus_ids": [
      "1"
    ],
    "end_at": "2017-11-29 13:43:10 UTC",
    "ip_range": "10.20.0.0/16",
    "location": "Cluj",
    "max_people": "70",
    "name": "Rainbowcat Exam 🌈",
    "project_ids": [
      "3"
    ],
    "visible": "true"
  }
}
201
{
  "id": 3,
  "ip_range": "10.20.0.0/16",
  "begin_at": "2017-11-25T13:43:10.000Z",
  "end_at": "2017-11-29T13:43:10.000Z",
  "location": "Cluj",
  "max_people": 70,
  "nbr_subscribers": 0,
  "name": "Rainbowcat Exam 🌈",
  "campus": [
    {
      "id": 1,
      "name": "Cluj",
      "time_zone": "Europe/Bucharest",
      "language": {
        "id": 3,
        "name": "Romanian",
        "identifier": "ro",
        "created_at": "2017-11-22T13:40:59.468Z",
        "updated_at": "2017-11-22T13:41:26.139Z"
      },
      "users_count": 28,
      "vogsphere_id": 1
    }
  ],
  "cursus": [
    {
      "id": 1,
      "created_at": "2017-11-22T13:41:00.750Z",
      "name": "Piscine C",
      "slug": "piscine-c"
    }
  ],
  "projects": [
    {
      "id": 3,
      "name": "Metaprogramming in OCaml",
      "slug": "metaprogramming-in-ocaml",
      "description": "Something you shouldn't see",
      "parent": null,
      "children": [],
      "objectives": [
        "Run away"
      ],
      "tier": 1,
      "attachments": [],
      "created_at": "2017-11-22T13:41:26.537Z",
      "updated_at": "2017-11-22T13:41:26.616Z",
      "exam": true
    }
  ]
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"exam":{"begin_at":"2017-11-25 13:43:10 UTC","campus_ids":["1"],"end_at":"2017-11-29 13:43:10 UTC","ip_range":"10.20.0.0/16","location":"Cluj","max_people":"70","name":"Rainbowcat Exam 🌈","project_ids":["3"],"visible":"true"}}' "https://api.intra.42.fr/v2/exams"

{
  "id": 3,
  "ip_range": "10.20.0.0/16",
  "begin_at": "2017-11-25T13:43:10.000Z",
  "end_at": "2017-11-29T13:43:10.000Z",
  "location": "Cluj",
  "max_people": 70,
  "nbr_subscribers": 0,
  "name": "Rainbowcat Exam 🌈",
  "campus": [
    {
      "id": 1,
      "name": "Cluj",
      "time_zone": "Europe/Bucharest",
      "language": {
        "id": 3,
        "name": "Romanian",
        "identifier": "ro",
        "created_at": "2017-11-22T13:40:59.468Z",
        "updated_at": "2017-11-22T13:41:26.139Z"
      },
      "users_count": 28,
      "vogsphere_id": 1
    }
  ],
  "cursus": [
    {
      "id": 1,
      "created_at": "2017-11-22T13:41:00.750Z",
      "name": "Piscine C",
      "slug": "piscine-c"
    }
  ],
  "projects": [
    {
      "id": 3,
      "name": "Metaprogramming in OCaml",
      "slug": "metaprogramming-in-ocaml",
      "description": "Something you shouldn't see",
      "parent": null,
      "children": [],
      "objectives": [
        "Run away"
      ],
      "tier": 1,
      "attachments": [],
      "created_at": "2017-11-22T13:41:26.537Z",
      "updated_at": "2017-11-22T13:41:26.616Z",
      "exam": true
    }
  ]
}
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 = {exam: {begin_at: "2017-11-25 13:43:10 UTC", campus_ids: ["1"], end_at: "2017-11-29 13:43:10 UTC", ip_range: "10.20.0.0/16", location: "Cluj", max_people: "70", name: "Rainbowcat Exam 🌈", project_ids: ["3"], visible: "true"}}
response = token.post("/v2/exams", params: params)
response.status
# => 201
response.parsed
# => {"id"=>3, "ip_range"=>"10.20.0.0/16", "begin_at"=>"2017-11-25T13:43:10.000Z", "end_at"=>"2017-11-29T13:43:10.000Z", "location"=>"Cluj", "max_people"=>70, "nbr_subscribers"=>0, "name"=>"Rainbowcat Exam 🌈", "campus"=>[{"id"=>1, "name"=>"Cluj", "time_zone"=>"Europe/Bucharest", "language"=>{"id"=>3, "name"=>"Romanian", "identifier"=>"ro", "created_at"=>"2017-11-22T13:40:59.468Z", "updated_at"=>"2017-11-22T13:41:26.139Z"}, "users_count"=>28, "vogsphere_id"=>1}], "cursus"=>[{"id"=>1, "created_at"=>"2017-11-22T13:41:00.750Z", "name"=>"Piscine C", "slug"=>"piscine-c"}], "projects"=>[{"id"=>3, "name"=>"Metaprogramming in OCaml", "slug"=>"metaprogramming-in-ocaml", "description"=>"Something you shouldn't see", "parent"=>nil, "children"=>[], "objectives"=>["Run away"], "tier"=>1, "attachments"=>[], "created_at"=>"2017-11-22T13:41:26.537Z", "updated_at"=>"2017-11-22T13:41:26.616Z", "exam"=>true}]}