live_help Notes

assignment This action requires one of theses roles: Advanced tutor

settings Params

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

The bloc id.

coalition[user_id] required . Must be Fixnum

The user id.

coalition[name] required . Must be String

The name. Must be unique in the scope of a given bloc.

coalition[image] required . Must be File

The image.

coalition[slug] optional , nil allowed . Must be String

The slug.

coalition[color] required . Must be String

The color.

coalition[cover] optional , nil allowed . Must be File

The cover.

POST /v2/coalitions
{
  "coalition": {
    "name": "rabbits",
    "bloc_id": "1",
    "user_id": "35",
    "image": {
      "tempfile": [],
      "original_filename": "logo.svg",
      "content_type": "image/svg+xml",
      "headers": "Content-Disposition: form-data; name=\"coalition[image]\"; filename=\"logo.svg\"\r\nContent-Type: image/svg+xml\r\nContent-Length: 2989\r\n"
    },
    "color": "#4231d7"
  }
}
201
{
  "id": 3,
  "name": "rabbits",
  "slug": "rabbits",
  "image_url": "https://admin.intra.42.fr/uploads/coalition/image/3/logo.svg",
  "color": "#4231d7",
  "score": 0,
  "user_id": 35
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"coalition":{"name":"rabbits","bloc_id":"1","user_id":"35","image":{"tempfile":[],"original_filename":"logo.svg","content_type":"image/svg+xml","headers":"Content-Disposition: form-data; name=\"coalition[image]\"; filename=\"logo.svg\"\r\nContent-Type: image/svg+xml\r\nContent-Length: 2989\r\n"},"color":"#4231d7"}}' "https://api.intra.42.fr/v2/coalitions"

{
  "id": 3,
  "name": "rabbits",
  "slug": "rabbits",
  "image_url": "https://admin.intra.42.fr/uploads/coalition/image/3/logo.svg",
  "color": "#4231d7",
  "score": 0,
  "user_id": 35
}
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 = {coalition: {name: "rabbits", bloc_id: "1", user_id: "35", image: {tempfile: [], original_filename: "logo.svg", content_type: "image/svg+xml", headers: "Content-Disposition: form-data; name="coalition[image]"; filename="logo.svg"
Content-Type: image/svg+xml
Content-Length: 2989
"}, color: "#4231d7"}}
response = token.post("/v2/coalitions", params: params)
response.status
# => 201
response.parsed
# => {"id"=>3, "name"=>"rabbits", "slug"=>"rabbits", "image_url"=>"https://admin.intra.42.fr/uploads/coalition/image/3/logo.svg", "color"=>"#4231d7", "score"=>0, "user_id"=>35}