live_help Notes

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

settings Params

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

The name. Must be unique.

notion[tag_ids] optional , nil allowed . Must be an array of Integer

The tag ids.

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

The cursus ids.

notion[subnotions_attributes] optional , nil allowed . Must be an Array of nested elements

The subnotions attributes.

notion[subnotions_attributes][id] optional , nil allowed . Must be Fixnum

The id.

notion[subnotions_attributes][name] required . Must be String

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

notion[subnotions_attributes][_destroy] optional , nil allowed . Must be String

The destroy.

notion[subnotions_attributes][attachments_attributes] optional , nil allowed . Must be an Array of nested elements

The attachments attributes.

notion[subnotions_attributes][attachments_attributes][id] optional , nil allowed . Must be Fixnum

The id.

notion[subnotions_attributes][attachments_attributes][kind] optional , nil allowed . Must be one of: code, pdf, link, document, video.

The kind.

notion[subnotions_attributes][attachments_attributes][_destroy] optional , nil allowed . Must be String

The destroy.

notion[subnotions_attributes][attachments_attributes][language_id] required . Must be Fixnum

The language id.

notion[subnotions_attributes][attachments_attributes][untranslatable] optional , nil allowed . Must be one of: true, false.

Is it untranslatable ? Default to false.

notion[subnotions_attributes][attachments_attributes][attachable_attributes] optional , nil allowed . Must be an Array of nested elements

The attachable attributes.

POST /v2/notions
{
  "notion": {
    "cursus_ids": [
      "2"
    ],
    "name": "Metafiction",
    "subnotions_attributes": [
      {
        "name": "Postern of Fate"
      }
    ],
    "tag_ids": [
      "2",
      "3",
      "6"
    ]
  }
}
201
{
  "id": 11,
  "name": "Metafiction",
  "slug": "metafiction",
  "created_at": "2017-11-22T13:43:48.180Z",
  "subnotions": [
    {
      "id": 11,
      "name": "Postern of Fate",
      "slug": "postern-of-fate",
      "created_at": "2017-11-22T13:43:48.192Z",
      "notepad": null
    }
  ],
  "tags": [
    {
      "id": 2,
      "name": "Friends with Benefits",
      "kind": "project"
    },
    {
      "id": 3,
      "name": "GBmu",
      "kind": "project"
    },
    {
      "id": 6,
      "name": "Jour 13",
      "kind": "project"
    }
  ],
  "cursus": [
    {
      "id": 2,
      "created_at": "2017-11-22T13:41:00.825Z",
      "name": "42",
      "slug": "42"
    }
  ]
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"notion":{"cursus_ids":["2"],"name":"Metafiction","subnotions_attributes":[{"name":"Postern of Fate"}],"tag_ids":["2","3","6"]}}' "https://api.intra.42.fr/v2/notions"

{
  "id": 11,
  "name": "Metafiction",
  "slug": "metafiction",
  "created_at": "2017-11-22T13:43:48.180Z",
  "subnotions": [
    {
      "id": 11,
      "name": "Postern of Fate",
      "slug": "postern-of-fate",
      "created_at": "2017-11-22T13:43:48.192Z",
      "notepad": null
    }
  ],
  "tags": [
    {
      "id": 2,
      "name": "Friends with Benefits",
      "kind": "project"
    },
    {
      "id": 3,
      "name": "GBmu",
      "kind": "project"
    },
    {
      "id": 6,
      "name": "Jour 13",
      "kind": "project"
    }
  ],
  "cursus": [
    {
      "id": 2,
      "created_at": "2017-11-22T13:41:00.825Z",
      "name": "42",
      "slug": "42"
    }
  ]
}
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 = {notion: {cursus_ids: ["2"], name: "Metafiction", subnotions_attributes: [{name: "Postern of Fate"}], tag_ids: ["2", "3", "6"]}}
response = token.post("/v2/notions", params: params)
response.status
# => 201
response.parsed
# => {"id"=>11, "name"=>"Metafiction", "slug"=>"metafiction", "created_at"=>"2017-11-22T13:43:48.180Z", "subnotions"=>[{"id"=>11, "name"=>"Postern of Fate", "slug"=>"postern-of-fate", "created_at"=>"2017-11-22T13:43:48.192Z", "notepad"=>nil}], "tags"=>[{"id"=>2, "name"=>"Friends with Benefits", "kind"=>"project"}, {"id"=>3, "name"=>"GBmu", "kind"=>"project"}, {"id"=>6, "name"=>"Jour 13", "kind"=>"project"}], "cursus"=>[{"id"=>2, "created_at"=>"2017-11-22T13:41:00.825Z", "name"=>"42", "slug"=>"42"}]}