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": "94",
    "cursus_ids": [
      "1"
    ],
    "kind": "normal",
    "language_id": "3",
    "messages_attributes": [
      {
        "author_id": "21",
        "content": "Hello world",
        "messageable_id": "1",
        "messageable_type": "Topic"
      }
    ],
    "name": "The daily unicorn #837 🦄",
    "tag_ids": [
      "9",
      "7",
      "8"
    ]
  }
}
201
{
  "id": 11,
  "name": "The daily unicorn #837 🦄",
  "author": {
    "id": 94,
    "login": "chewchew",
    "url": "https://api.intra.42.fr/v2/users/chewchew"
  },
  "kind": "normal",
  "created_at": "2017-11-22T13:44:14.883Z",
  "updated_at": "2017-11-22T13:44:14.960Z",
  "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/11/messages",
  "message": {
    "id": 104,
    "content": {
      "markdown": "Hello world",
      "html": null
    }
  },
  "tags": [
    {
      "id": 9,
      "name": "Lost and found",
      "kind": "general"
    },
    {
      "id": 7,
      "name": "Bocal",
      "kind": "general"
    },
    {
      "id": 8,
      "name": "WTF?!",
      "kind": "general"
    }
  ]
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"topic":{"author_id":"94","cursus_ids":["1"],"kind":"normal","language_id":"3","messages_attributes":[{"author_id":"21","content":"Hello world","messageable_id":"1","messageable_type":"Topic"}],"name":"The daily unicorn #837 🦄","tag_ids":["9","7","8"]}}' "https://api.intra.42.fr/v2/topics.json"

{
  "id": 11,
  "name": "The daily unicorn #837 🦄",
  "author": {
    "id": 94,
    "login": "chewchew",
    "url": "https://api.intra.42.fr/v2/users/chewchew"
  },
  "kind": "normal",
  "created_at": "2017-11-22T13:44:14.883Z",
  "updated_at": "2017-11-22T13:44:14.960Z",
  "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/11/messages",
  "message": {
    "id": 104,
    "content": {
      "markdown": "Hello world",
      "html": null
    }
  },
  "tags": [
    {
      "id": 9,
      "name": "Lost and found",
      "kind": "general"
    },
    {
      "id": 7,
      "name": "Bocal",
      "kind": "general"
    },
    {
      "id": 8,
      "name": "WTF?!",
      "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: "94", cursus_ids: ["1"], kind: "normal", language_id: "3", messages_attributes: [{author_id: "21", content: "Hello world", messageable_id: "1", messageable_type: "Topic"}], name: "The daily unicorn #837 🦄", tag_ids: ["9", "7", "8"]}}
response = token.post("/v2/topics.json", params: params)
response.status
# => 201
response.parsed
# => {"id"=>11, "name"=>"The daily unicorn #837 \u{1F984}", "author"=>{"id"=>94, "login"=>"chewchew", "url"=>"https://api.intra.42.fr/v2/users/chewchew"}, "kind"=>"normal", "created_at"=>"2017-11-22T13:44:14.883Z", "updated_at"=>"2017-11-22T13:44:14.960Z", "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/11/messages", "message"=>{"id"=>104, "content"=>{"markdown"=>"Hello world", "html"=>nil}}, "tags"=>[{"id"=>9, "name"=>"Lost and found", "kind"=>"general"}, {"id"=>7, "name"=>"Bocal", "kind"=>"general"}, {"id"=>8, "name"=>"WTF?!", "kind"=>"general"}]}