live_help Notes

assignment This action requires one of theses roles: Advanced tutor, Achievements manager

settings Params

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

The name.

achievement[internal_name] required . Must be String

The internal name.

achievement[description] required . Must be String

The description. Maximum length is 140.

achievement[pedago] optional , nil allowed . Must be one of: true, false.

Is it pedago ? Default to false.

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

Is it visible ? Default to false.

achievement[nbr_of_success] optional , nil allowed . Must be Fixnum

The nbr of success.

achievement[parent_id] optional , nil allowed . Must be Fixnum

The parent id.

achievement[image_cache] optional , nil allowed . Must be String

The image cache.

achievement[image] optional , nil allowed . Must be File

The image.

achievement[kind] required . Must be one of: project, social, scolarity, pedagogy.

The kind.

achievement[title_id] optional , nil allowed . Must be Fixnum

The title id.

achievement[tier] required . Must be one of: none, easy, medium, hard, challenge.

The tier.

achievement[lg] optional , nil allowed . Must be String

The language id.

achievement[position] optional , nil allowed . Must be Fixnum

The position.

achievement[reward] optional , nil allowed . Must be String

The reward.

achievement[cursus_ids] optional , nil allowed . Must be an array of Integer

The cursus ids.

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

The campus ids.

achievement[community_services_attributes] optional , nil allowed . Must be an Array of nested elements

The community services attributes.

achievement[community_services_attributes][duration] required . Must be Fixnum

The duration.

achievement[community_services_attributes][occupation] optional , nil allowed . Must be String

The occupation.

achievement[community_services_attributes][id] optional , nil allowed . Must be Fixnum

The id.

achievement[community_services_attributes][_destroy] optional , nil allowed . Must be String

The destroy.

comments powered by <span class='logo-disqus'>Disqus</span>
POST /v2/achievements
{
  "achievement": {
    "name": "Be a test of the API",
    "internal_name": "BeATestAPI",
    "kind": "social",
    "tier": "none",
    "description": "Be used as a test for the api",
    "image": {
      "tempfile": [],
      "original_filename": "logo.svg",
      "content_type": "image/svg+xml",
      "headers": "Content-Disposition: form-data; name=\"achievement[image]\"; filename=\"logo.svg\"\r\nContent-Type: image/svg+xml\r\nContent-Length: 2989\r\n"
    },
    "title_id": "30",
    "cursus_ids": [
      "1"
    ],
    "campus_ids": [
      "1"
    ],
    "lg": "1"
  }
}
201
{
  "id": 11,
  "name": "Be a test of the API",
  "description": "Be used as a test for the api",
  "tier": "none",
  "kind": "social",
  "visible": false,
  "image": "/uploads/achievement/image/11/logo.svg",
  "nbr_of_success": null,
  "users_url": "https://api.intra.42.fr/v2/achievements/11/users",
  "achievements": [],
  "parent": null,
  "title": null
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"achievement":{"name":"Be a test of the API","internal_name":"BeATestAPI","kind":"social","tier":"none","description":"Be used as a test for the api","image":{"tempfile":[],"original_filename":"logo.svg","content_type":"image/svg+xml","headers":"Content-Disposition: form-data; name=\"achievement[image]\"; filename=\"logo.svg\"\r\nContent-Type: image/svg+xml\r\nContent-Length: 2989\r\n"},"title_id":"30","cursus_ids":["1"],"campus_ids":["1"],"lg":"1"}}' "https://api.intra.42.fr/v2/achievements"

{
  "id": 11,
  "name": "Be a test of the API",
  "description": "Be used as a test for the api",
  "tier": "none",
  "kind": "social",
  "visible": false,
  "image": "/uploads/achievement/image/11/logo.svg",
  "nbr_of_success": null,
  "users_url": "https://api.intra.42.fr/v2/achievements/11/users",
  "achievements": [],
  "parent": null,
  "title": 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 = {achievement: {name: "Be a test of the API", internal_name: "BeATestAPI", kind: "social", tier: "none", description: "Be used as a test for the api", image: {tempfile: [], original_filename: "logo.svg", content_type: "image/svg+xml", headers: "Content-Disposition: form-data; name="achievement[image]"; filename="logo.svg"
Content-Type: image/svg+xml
Content-Length: 2989
"}, title_id: "30", cursus_ids: ["1"], campus_ids: ["1"], lg: "1"}}
response = token.post("/v2/achievements", params: params)
response.status
# => 201
response.parsed
# => {"id"=>11, "name"=>"Be a test of the API", "description"=>"Be used as a test for the api", "tier"=>"none", "kind"=>"social", "visible"=>false, "image"=>"/uploads/achievement/image/11/logo.svg", "nbr_of_success"=>nil, "users_url"=>"https://api.intra.42.fr/v2/achievements/11/users", "achievements"=>[], "parent"=>nil, "title"=>nil}