live_help Notes

assignment_ind This action requires a token resource owner scoped on forum with enough privileges .

settings Params

Param name Description
topic_id optional . Must be String

The topic id

message_id optional . Must be String

The message id

message optional , nil allowed . Must be a Hash
message[author_id] required . Must be Fixnum

The author id.

message[content] required . Must be String

The content.

message[content_html] optional , nil allowed . Must be String

The content html.

message[parent_id] optional , nil allowed . Must be Fixnum

The parent id.

message[reference_id] optional , nil allowed . Must be Fixnum

The reference id.

message[deleted_at] optional , nil allowed . Must be DateTime

The deleted at.

message[is_root] optional , nil allowed . Must be one of: true, false.

Is it is root ? Default to false.

message[messageable_type] optional , nil allowed . Must be String

The messageable type.

message[messageable_id] optional , nil allowed . Must be Fixnum

The messageable id.

message[write_at] optional , nil allowed . Must be DateTime

The write at.

message[readings_count] optional , nil allowed . Must be Fixnum

The readings count. Default to 0.

comments powered by <span class='logo-disqus'>Disqus</span>
POST /v2/messages
{
  "message": {
    "author_id": "60",
    "content": "Hello world",
    "messageable_id": "7",
    "messageable_type": "Topic"
  }
}
201
{
  "id": 104,
  "author": {
    "id": 60,
    "login": "leiorgan",
    "url": "https://api.intra.42.fr/v2/users/leiorgan"
  },
  "content": "Hello world",
  "content_html": null,
  "replies": [],
  "created_at": "2017-03-06T15:20:20.436Z",
  "updated_at": "2017-03-06T15:20:20.436Z",
  "parent_id": null,
  "is_root": false,
  "messageable_id": 7,
  "messageable_type": "Topic",
  "votes_count": {
    "upvote": 0,
    "downvote": 0,
    "trollvote": 0,
    "problem": 0
  },
  "user_votes": {
    "upvote": false,
    "downvote": false,
    "trollvote": false,
    "problem": false
  },
  "readings": 0
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"message":{"author_id":"60","content":"Hello world","messageable_id":"7","messageable_type":"Topic"}}' "https://api.intra.42.fr/v2/messages"

{
  "id": 104,
  "author": {
    "id": 60,
    "login": "leiorgan",
    "url": "https://api.intra.42.fr/v2/users/leiorgan"
  },
  "content": "Hello world",
  "content_html": null,
  "replies": [],
  "created_at": "2017-03-06T15:20:20.436Z",
  "updated_at": "2017-03-06T15:20:20.436Z",
  "parent_id": null,
  "is_root": false,
  "messageable_id": 7,
  "messageable_type": "Topic",
  "votes_count": {
    "upvote": 0,
    "downvote": 0,
    "trollvote": 0,
    "problem": 0
  },
  "user_votes": {
    "upvote": false,
    "downvote": false,
    "trollvote": false,
    "problem": false
  },
  "readings": 0
}
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 = {message: {author_id: "60", content: "Hello world", messageable_id: "7", messageable_type: "Topic"}}
response = token.post("/v2/messages", params: params)
response.status
# => 201
response.parsed
# => {"id"=>104, "author"=>{"id"=>60, "login"=>"leiorgan", "url"=>"https://api.intra.42.fr/v2/users/leiorgan"}, "content"=>"Hello world", "content_html"=>nil, "replies"=>[], "created_at"=>"2017-03-06T15:20:20.436Z", "updated_at"=>"2017-03-06T15:20:20.436Z", "parent_id"=>nil, "is_root"=>false, "messageable_id"=>7, "messageable_type"=>"Topic", "votes_count"=>{"upvote"=>0, "downvote"=>0, "trollvote"=>0, "problem"=>0}, "user_votes"=>{"upvote"=>false, "downvote"=>false, "trollvote"=>false, "problem"=>false}, "readings"=>0}