live_help Notes

assignment_ind This action requires a token resource owner scoped on projects with enough privileges or an application with one of theses role(s): Advanced tutor .

settings Params

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

The project id.

team[name] optional , nil allowed . Must be String

The name. Maximum length is 255.

team[created_at] optional , nil allowed . Must be DateTime

The created at.

team[updated_at] optional , nil allowed . Must be DateTime

The updated at.

team[locked_at] optional , nil allowed . Must be DateTime

The locked at.

team[closed_at] optional , nil allowed . Must be DateTime

The closed at.

team[final_mark] optional , nil allowed . Must be Fixnum

The final mark.

team[repo_url] optional , nil allowed . Must be String

The repo url.

team[repo_uuid] optional , nil allowed . Must be String

The repo uuid.

team[deadline_at] optional , nil allowed . Must be Fixnum

The deadline at. Must be after today.

team[terminating_at] optional , nil allowed . Must be DateTime

The terminating at.

team[teams_users_attributes] optional , nil allowed . Must be an Array of nested elements

The teams users attributes.

team[teams_users_attributes][user_id] required . Must be Fixnum

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

team[teams_users_attributes][leader] optional , nil allowed . Must be one of: true, false.

Is it leader ? Default to false.

team[teams_users_attributes][validated] optional , nil allowed . Must be one of: true, false.

Is it validated ? Default to false.

team[teams_users_attributes][occurrence] optional , nil allowed . Must be Fixnum

The occurrence. Default to 0.

POST /v2/teams
{
  "team": {
    "name": "Awesome team",
    "project_id": 688,
    "teams_users_attributes": [
      {
        "user_id": 17282,
        "leader": true
      },
      {
        "user_id": 18668
      },
      {
        "user_id": 15646
      },
      {
        "user_id": 12293
      },
      {
        "user_id": 17241
      }
    ]
  }
}
201
{
  "closed?": false,
  "closed_at": null,
  "created_at": "2019-01-29T13:46:58.977Z",
  "final_mark": null,
  "id": 2368475,
  "locked?": false,
  "locked_at": null,
  "name": "soin",
  "project_id": 688,
  "project_session_id": 431,
  "repo_url": null,
  "repo_uuid": "intra-uuid-ed68a876-be55-42ff-af85-43826f014fb5-2368475",
  "scale_teams": [],
  "status": "creating_group",
  "teams_uploads": [],
  "terminating_at": null,
  "updated_at": "2019-01-29T13:46:59.104Z",
  "url": "http://localhost:13000/v2/teams/2368475",
  "users": [
    {
      "id": 12293,
      "leader": false,
      "login": "mcanal",
      "occurrence": 0,
      "projects_user_id": 824439,
      "url": "http://localhost:13000/v2/users/mcanal",
      "validated": false
    },
    {
      "id": 15646,
      "leader": false,
      "login": "qduperon",
      "occurrence": 0,
      "projects_user_id": 802915,
      "url": "http://localhost:13000/v2/users/qduperon",
      "validated": false
    },
    {
      "id": 17241,
      "leader": false,
      "login": "mmoullec",
      "occurrence": 0,
      "projects_user_id": 1149166,
      "url": "http://localhost:13000/v2/users/mmoullec",
      "validated": false
    },
    {
      "id": 17282,
      "leader": true,
      "login": "thifranc",
      "occurrence": 0,
      "projects_user_id": 1149194,
      "url": "http://localhost:13000/v2/users/thifranc",
      "validated": false
    },
    {
      "id": 18668,
      "leader": false,
      "login": "jlasne",
      "occurrence": 0,
      "projects_user_id": 1097141,
      "url": "http://localhost:13000/v2/users/jlasne",
      "validated": false
    }
  ],
  "validated?": null
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"team":{"name":"Awesome team","project_id":688,"teams_users_attributes":[{"user_id":17282,"leader":true},{"user_id":18668},{"user_id":15646},{"user_id":12293},{"user_id":17241}]}}' "https://api.intra.42.fr/v2/teams"

{
  "closed?": false,
  "closed_at": null,
  "created_at": "2019-01-29T13:46:58.977Z",
  "final_mark": null,
  "id": 2368475,
  "locked?": false,
  "locked_at": null,
  "name": "soin",
  "project_id": 688,
  "project_session_id": 431,
  "repo_url": null,
  "repo_uuid": "intra-uuid-ed68a876-be55-42ff-af85-43826f014fb5-2368475",
  "scale_teams": [],
  "status": "creating_group",
  "teams_uploads": [],
  "terminating_at": null,
  "updated_at": "2019-01-29T13:46:59.104Z",
  "url": "http://localhost:13000/v2/teams/2368475",
  "users": [
    {
      "id": 12293,
      "leader": false,
      "login": "mcanal",
      "occurrence": 0,
      "projects_user_id": 824439,
      "url": "http://localhost:13000/v2/users/mcanal",
      "validated": false
    },
    {
      "id": 15646,
      "leader": false,
      "login": "qduperon",
      "occurrence": 0,
      "projects_user_id": 802915,
      "url": "http://localhost:13000/v2/users/qduperon",
      "validated": false
    },
    {
      "id": 17241,
      "leader": false,
      "login": "mmoullec",
      "occurrence": 0,
      "projects_user_id": 1149166,
      "url": "http://localhost:13000/v2/users/mmoullec",
      "validated": false
    },
    {
      "id": 17282,
      "leader": true,
      "login": "thifranc",
      "occurrence": 0,
      "projects_user_id": 1149194,
      "url": "http://localhost:13000/v2/users/thifranc",
      "validated": false
    },
    {
      "id": 18668,
      "leader": false,
      "login": "jlasne",
      "occurrence": 0,
      "projects_user_id": 1097141,
      "url": "http://localhost:13000/v2/users/jlasne",
      "validated": false
    }
  ],
  "validated?": null
}
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 = {team: {name: "Awesome team", project_id: 688, teams_users_attributes: [{user_id: 17282, leader: true}, {user_id: 18668}, {user_id: 15646}, {user_id: 12293}, {user_id: 17241}]}}
response = token.post("/v2/teams", params: params)
response.status
# => 201
response.parsed
# => {"closed?"=>false, "closed_at"=>nil, "created_at"=>"2019-01-29T13:46:58.977Z", "final_mark"=>nil, "id"=>2368475, "locked?"=>false, "locked_at"=>nil, "name"=>"soin", "project_id"=>688, "project_session_id"=>431, "repo_url"=>nil, "repo_uuid"=>"intra-uuid-ed68a876-be55-42ff-af85-43826f014fb5-2368475", "scale_teams"=>[], "status"=>"creating_group", "teams_uploads"=>[], "terminating_at"=>nil, "updated_at"=>"2019-01-29T13:46:59.104Z", "url"=>"http://localhost:13000/v2/teams/2368475", "users"=>[{"id"=>12293, "leader"=>false, "login"=>"mcanal", "occurrence"=>0, "projects_user_id"=>824439, "url"=>"http://localhost:13000/v2/users/mcanal", "validated"=>false}, {"id"=>15646, "leader"=>false, "login"=>"qduperon", "occurrence"=>0, "projects_user_id"=>802915, "url"=>"http://localhost:13000/v2/users/qduperon", "validated"=>false}, {"id"=>17241, "leader"=>false, "login"=>"mmoullec", "occurrence"=>0, "projects_user_id"=>1149166, "url"=>"http://localhost:13000/v2/users/mmoullec", "validated"=>false}, {"id"=>17282, "leader"=>true, "login"=>"thifranc", "occurrence"=>0, "projects_user_id"=>1149194, "url"=>"http://localhost:13000/v2/users/thifranc", "validated"=>false}, {"id"=>18668, "leader"=>false, "login"=>"jlasne", "occurrence"=>0, "projects_user_id"=>1097141, "url"=>"http://localhost:13000/v2/users/jlasne", "validated"=>false}], "validated?"=>nil}