function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Need the sample code to set request body for POST method



Can anyone send me the reference document or sample code (in Java) to set request body values for a POST method?


It would be grateful if you send me the code fro this sample data.



   "body" : {
      "messageSegments" : [
         "type": "mention",
         "id" : "005D0000001GpHp"
         "type": "text",
         "text" : " Did you see the new plans?"





Here is an example in Ruby. A post is effectively a HTTP POST. The trick is setting up the json response correctly (see the snippet below):


def self.set_my_user_status(post)
    options = Chatter.set_http_options
    options.merge!( :body => { :body => { :messageSegments => [
                                  :type => "Text",
                                  :text => post.body
   puts @options
    @response ="/feeds/news/me/feed-items", options)