If you want to link a community service with this close, pass it trough the community_services_attributes array attribute. An email is automatically sent to the user when he is assigned to a community service.

live_help Notes

assignment This action requires one of theses roles: Basic staff
group_work Requires following application scopes: tig

settings Params

Param name Description
user_id optional . Must be String

The user id or slug

close optional , nil allowed . Must be a Hash
close[user_id] required . Must be Fixnum

The closed user

close[closer_id] required . Must be Fixnum

The closer, defaults to the token owner if there is one

close[kind] required . Must be one of: other, deserter, black_hole, serious_misconduct, social_security, non_admitted.

The close kind

close[reason] required . Must be String

The reason of this close

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

The linked community service(s)

close[community_services_attributes][duration] required . Must be one of: 7200, 14400, 28800.

The community service duration in seconds. Must be 2 hours, 4 hours or 8 hours.

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

The community service occupation

comments powered by <span class='logo-disqus'>Disqus</span>
POST /v2/closes
{
  "close": {
    "closer_id": "1",
    "kind": "other",
    "reason": "Mange des patates douces en cluster 🍠",
    "state": "close",
    "user_id": "57"
  }
}
201
{
  "id": 8,
  "reason": "Mange des patates douces en cluster 🍠",
  "state": "close",
  "created_at": "2017-03-06T15:20:08.484Z",
  "updated_at": "2017-03-06T15:20:08.484Z",
  "community_services": [],
  "user": {
    "id": 57,
    "login": "kiki-adi",
    "url": "https://api.intra.42.fr/v2/users/kiki-adi"
  },
  "closer": {
    "id": 1,
    "login": "jeanne",
    "url": "https://api.intra.42.fr/v2/users/jeanne"
  }
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"close":{"closer_id":"1","kind":"other","reason":"Mange des patates douces en cluster 🍠","state":"close","user_id":"57"}}' "https://api.intra.42.fr/v2/closes"

{
  "id": 8,
  "reason": "Mange des patates douces en cluster 🍠",
  "state": "close",
  "created_at": "2017-03-06T15:20:08.484Z",
  "updated_at": "2017-03-06T15:20:08.484Z",
  "community_services": [],
  "user": {
    "id": 57,
    "login": "kiki-adi",
    "url": "https://api.intra.42.fr/v2/users/kiki-adi"
  },
  "closer": {
    "id": 1,
    "login": "jeanne",
    "url": "https://api.intra.42.fr/v2/users/jeanne"
  }
}
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 = {close: {closer_id: "1", kind: "other", reason: "Mange des patates douces en cluster 🍠", state: "close", user_id: "57"}}
response = token.post("/v2/closes", params: params)
response.status
# => 201
response.parsed
# => {"id"=>8, "reason"=>"Mange des patates douces en cluster 🍠", "state"=>"close", "created_at"=>"2017-03-06T15:20:08.484Z", "updated_at"=>"2017-03-06T15:20:08.484Z", "community_services"=>[], "user"=>{"id"=>57, "login"=>"kiki-adi", "url"=>"https://api.intra.42.fr/v2/users/kiki-adi"}, "closer"=>{"id"=>1, "login"=>"jeanne", "url"=>"https://api.intra.42.fr/v2/users/jeanne"}}