live_help Notes

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

settings Params

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

The name.

topic[kind] required . Must be one of: normal, survey, stack_overflow.

The kind.

topic[language_id] required . Must be Fixnum

The language id.

topic[author_id] optional , nil allowed . Must be Fixnum

The author id.

topic[messages_attributes] optional , nil allowed . Must be an Array of nested elements

The messages attributes.

topic[messages_attributes][content] required . Must be String

The content.

topic[messages_attributes][id] optional , nil allowed . Must be Fixnum

The id.

topic[messages_attributes][author_id] required . Must be Fixnum

The author id.

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

The tag ids.

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

The cursus ids.

topic[survey_attributes] optional , nil allowed . Must be an Array of nested elements

The survey attributes.

topic[survey_attributes][name] required . Must be String

The name.

topic[survey_attributes][expire_at] optional , nil allowed . Must be DateTime

The expire at.

topic[survey_attributes][id] optional , nil allowed . Must be Fixnum

The id.

topic[survey_attributes][_destroy] optional , nil allowed . Must be String

The destroy.

topic[survey_attributes][survey_answers_attributes] optional , nil allowed . Must be an Array of nested elements

The survey answers attributes.

topic[survey_attributes][survey_answers_attributes][name] required . Must be String

The name.

topic[survey_attributes][survey_answers_attributes][id] optional , nil allowed . Must be Fixnum

The id.

topic[survey_attributes][survey_answers_attributes][_destroy] optional , nil allowed . Must be String

The destroy.

comments powered by <span class='logo-disqus'>Disqus</span>
POST /v2/topics.json
{
  "topic": {
    "author_id": "25",
    "cursus_ids": [
      "1"
    ],
    "kind": "normal",
    "language_id": "3",
    "name": "The daily unicorn #837 🦄",
    "tag_ids": [
      "13",
      "8",
      "7"
    ]
  }
}
201
{
  "id": 15,
  "name": "The daily unicorn #837 🦄",
  "author": {
    "id": 25,
    "login": "codooku",
    "url": "https://api.intra.42.fr/v2/users/codooku"
  },
  "kind": "normal",
  "created_at": "2017-03-06T15:20:46.848Z",
  "updated_at": "2017-03-06T15:20:46.865Z",
  "pinned_at": null,
  "locked_at": null,
  "pinner": null,
  "locker": null,
  "language": {
    "id": 3,
    "name": "Romanian",
    "identifier": "ro"
  },
  "messages_url": "https://api.intra.42.fr/v2/topics/15/messages",
  "message": null,
  "tags": [
    {
      "id": 13,
      "name": "Ordinary Wizarding Levels",
      "kind": "general"
    },
    {
      "id": 8,
      "name": "WTF?!",
      "kind": "general"
    },
    {
      "id": 7,
      "name": "Bocal",
      "kind": "general"
    }
  ]
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"topic":{"author_id":"25","cursus_ids":["1"],"kind":"normal","language_id":"3","name":"The daily unicorn #837 🦄","tag_ids":["13","8","7"]}}' "https://api.intra.42.fr/v2/topics.json"

{
  "id": 15,
  "name": "The daily unicorn #837 🦄",
  "author": {
    "id": 25,
    "login": "codooku",
    "url": "https://api.intra.42.fr/v2/users/codooku"
  },
  "kind": "normal",
  "created_at": "2017-03-06T15:20:46.848Z",
  "updated_at": "2017-03-06T15:20:46.865Z",
  "pinned_at": null,
  "locked_at": null,
  "pinner": null,
  "locker": null,
  "language": {
    "id": 3,
    "name": "Romanian",
    "identifier": "ro"
  },
  "messages_url": "https://api.intra.42.fr/v2/topics/15/messages",
  "message": null,
  "tags": [
    {
      "id": 13,
      "name": "Ordinary Wizarding Levels",
      "kind": "general"
    },
    {
      "id": 8,
      "name": "WTF?!",
      "kind": "general"
    },
    {
      "id": 7,
      "name": "Bocal",
      "kind": "general"
    }
  ]
}
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 = {topic: {author_id: "25", cursus_ids: ["1"], kind: "normal", language_id: "3", name: "The daily unicorn #837 🦄", tag_ids: ["13", "8", "7"]}}
response = token.post("/v2/topics.json", params: params)
response.status
# => 201
response.parsed
# => {"id"=>15, "name"=>"The daily unicorn #837 \u{1F984}", "author"=>{"id"=>25, "login"=>"codooku", "url"=>"https://api.intra.42.fr/v2/users/codooku"}, "kind"=>"normal", "created_at"=>"2017-03-06T15:20:46.848Z", "updated_at"=>"2017-03-06T15:20:46.865Z", "pinned_at"=>nil, "locked_at"=>nil, "pinner"=>nil, "locker"=>nil, "language"=>{"id"=>3, "name"=>"Romanian", "identifier"=>"ro"}, "messages_url"=>"https://api.intra.42.fr/v2/topics/15/messages", "message"=>nil, "tags"=>[{"id"=>13, "name"=>"Ordinary Wizarding Levels", "kind"=>"general"}, {"id"=>8, "name"=>"WTF?!", "kind"=>"general"}, {"id"=>7, "name"=>"Bocal", "kind"=>"general"}]}