• ChrisOctagon
  • SMARTIE
  • 660 Points
  • Member since 2011

  • Chatter
    Feed
  • 26
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 200
    Replies

Can we add a flag(boolean field) to Chatter posts so that we can do some calculations/DML for such feeds when they are inserted?

What kind, if any, limitations are set for Chatter External Users when using the REST API?

I want to add image to the content which  I am  posting to chatter.

I am using chatter rest api but not able to do it..

 

Any kind of help will be greatful.

 

I am using below code for uploading image to chatter post using restapi.

if (imageFile != null && fileName != null && imageTitle != null)
				{
					String url = salesforceRestClient.getClientInfo().instanceUrl + "/services/data/" + SF_API_VERSION + "/chatter/feeds/news/me/feed-items";
					HttpClient httpclient = new DefaultHttpClient();
					HttpPost httppost ;
					MultipartEntity reqEntity ;
					httppost = new HttpPost(url);
					reqEntity = new MultipartEntity(
							HttpMultipartMode.BROWSER_COMPATIBLE);
					FileBody bin = new FileBody(imageFile);
					reqEntity.addPart("feedItemFileUpload", bin);
					reqEntity.addPart("fileName", new StringBody(fileName, "text/html", Charset.defaultCharset()));
					reqEntity.addPart("text", new StringBody(noteContent, "text/html", Charset.defaultCharset()));
					reqEntity.addPart("feedItemFileUpload", new FileBody(imageFile, fileName, "application/octet-stream", Charset.defaultCharset().toString()));
					httppost.setEntity(reqEntity);
					httppost.setHeader("Authorization", "OAuth " + salesforceRestClient.getAuthToken());
					publishResponse = salesforceRestClient.sendSync(RestMethod.POST, url,reqEntity);
					NotepriseLogger.logMessage("responseBody"+publishResponse);
//					HttpResponse response = httpclient.execute(httppost);
//					HttpEntity resEntity = response.getEntity();

 Thanks

 

 

I have successfully able to post image to my own chatter wall but when I am posting it to user wall, it is giving me error. I am not able to take http request log some how.

 

Below is the code which I am using:

PostMethod postMethod = null;  

String stringBody = generateJSONBodyForChatterFeed(noteContent, selectedIds, null, fileName, imageTitle);      
String url = salesforceRestClient.getClientInfo().instanceUrl + "/services/data/" + SF_API_VERSION + "/chatter/feeds/news/me/feed-items";

Part[] parts = {
                                        new StringPart("desc", "Description"),
                                        new StringPart("fileName", fileName),
                                        new StringPart("text", noteContent),                                                                                
                                        new FilePart("feedItemFileUpload", imageFile),
                                    };
                        postMethod = new PostMethod(url);
                        postMethod.setRequestEntity(new MultipartRequestEntity(parts, postMethod.getParams()));

postMethod.setRequestHeader("Authorization", "OAuth " + salesforceRestClient.getAuthToken());                                
                    org.apache.commons.httpclient.HttpClient client = new org.apache.commons.httpclient.HttpClient();

 


 

Here is generateJSONBodyForChatterFeed method code:

 

public static String generateJSONBodyForChatterFeed(String content, ArrayList<String> mentionIds, String imageDescription, String fileName, String imageTitle)
    {
        JSONArray msg = new JSONArray();
        String bodyString = null;
        JSONObject requestJSON=null;
        try
        {            
            if (mentionIds != null)
            {
                for (int i = 0; i < mentionIds.size(); i++)
                {
                    JSONObject mention = new JSONObject();                
                    mention.put("type", "mention");
                    mention.put("id", mentionIds.get(i));
                    msg.put(mention);
                }                
            }
            if (content != null)
            {
                JSONObject text = new JSONObject();
                text.put("type", "text");
                
                text.put("text", " " + content);
                msg.put(text);
            }    
            JSONObject attachment = null;
            if (fileName != null && imageTitle != null)
            {
                attachment = new JSONObject();
                attachment.putOpt("desc", imageDescription);
                attachment.putOpt("fileName", fileName);
                attachment.putOpt("title", imageTitle);
            }
            requestJSON= new JSONObject();
            requestJSON.putOpt("body", new JSONObject().put("messageSegments", msg));
            if (attachment != null)
            {
                requestJSON.putOpt("attachment", attachment);
            }
            bodyString = requestJSON.toString();
            NotepriseLogger.logMessage("Json"+requestJSON);            
        }  
        catch (JSONException e)
        {
            e.printStackTrace();
        }
    
        return bodyString;
    }

 

 

Please let me know what mistake I am doing here. When I add bosy part , it is just skipping that and posting the image to my own wall instead of user.

 

Thanks

I've recently been receiving (503) Server Unavailable responses to Chatter API calls.

 

I suspect that I may be reaching the 200 call per user/hour limit, but would like to find a way to confirm.

 

Is there a place in the Salesforce UI where I can observe the number of Chatter API calls invoked per hour?  Or, is there an API method I can call?

Hi all,

 

I'm trying to figure out how I can @-mention a user via the Chatter API.. none of the following seem to work:

 

  • mentioning @[Steve Winton] # user's name in square brackets
  • mentioning @(Steve Winton) # user's name in round brackets
  • mentioning @"Steve Winton" # user's name in quotes
  • mentioning @{005E0000000Fpox} # user's ID in curly braces
  • mentioning @005E0000000Fpox # user's ID without curly braces

Is there a specific convention for this I should follow?

 

Many thanks,

Steve

I am trying to find ways to post Chatter private message to user.

 

Since there is no apex code directly to post Chatter private message to user, figured out there is a way in the REST APIs.

(Ref: http://www.salesforce.com/us/developer/docs/chatterapi/salesforce_chatter_rest_api.pdf)

/services/data/v24.0/chatter/users/me/messages?recipients=005D0000001GOYpIAO,
005D0000001GbdHIAS&Are+we+ready+for+next+week's+customer+meeting?

My question is, how do i call this in apex (Rest API's POST call)?

Since we are using internal salesforce rest api within the system, I am not sure if we should we use OAuth.

Can you please tell me how to call SF Rest api's using Apex?

 

  • April 20, 2012
  • Like
  • 0

Hello guys

I have a question about the chatter.

so far, I want to use chatter rest API to sent real time message to the users.

After do some research, I know it is easy to do this on the web page

But how to do the same things from the Android app?

below link is to show how to send message from the web page.

Could anybody can help me about this. thanks so much.

 

ps: in other hand, I can use mobile app to invoke the APEX class,

Know how to send real time message in APEX class also can resolve my question.

 

send chatter message from web page

 

Hi, I am a new Chatter App developer and I am trying to extract interactions between Chatter users in my organization.

The "@" or mention information is very important for my App, but it seems there is no documentation about how to get "@" information neither in SOQL nor in REST.

Can anybody tell me how to access "@" information? Many thanks in advance!

Hi,

 

Here is my scenario.  Let says that I have 2 different posts (i.e., 1: Issues, 2: Resources) posted on an Opportunity.  Base on certain criteria/keywords,a new comment (textpost) via API needs to be under the first post.  In this case, I already know opportunity id (parentid) but I can't query on body field.  How can I retrieve a correct feed id? Is it something that can be done if I don't want to keep track of all feed id & topic pairs of each opportunity?

 

Thanks for all the helps.

 

  • February 29, 2012
  • Like
  • 0

I'm developing a C# application to post items to a Chatter Group feed.  I can successfully post a text-only item, but I get an Error 400 trying to post a LinkPost type item.  Can anyone help with an example JSON data block that adds a LinkPost item?  I'm using V24.

Here's some JSON data that is NOT working for me:

{
	"type":"LinkPost",
	"body":{
		"messageSegments":[{
			"type":"text",
			"text":"some text here"
		}]
	},
	"attachment":{
		"title":"some link text",
		"url":"http://www.google.com"
	}
}

 

Thanks!

  • February 27, 2012
  • Like
  • 0

I'd like to detect which group a feeditem was posted to, and then use that information programmatically in a trigger. Is there a field on FeedItem taht tracks which group it was posted to? Or would I go through another means?

Hello all,

 

Is there a way to use the REST APIs to query for all the users that have a Chatter Influence Ranking of, let's say, 100 or less???

 

Saqib

Hello All,

 

Can anyone please tell how to retrieve (or form) the permalink for an individual item in the chatter feed using the Chatter APIs?

 

Saqib

Hi, I am new to Chatter REST API. Trying to get some samples working. However I found that when I try to retrieve my profile, in the version part of URL, I have used version 24.0 as specified in the documetnation assuming that could be the altest version. But, when I tried the profile API call(v24.0/chatter/users/me), It returned me 404 error. Then after spending some time boggling what is wrong, I tried with a different version number(in my case it is v23.0). Which has worked and returning me the profile info.

 

Now the question is How do I know version? Where do I find that?

 

 

Thanks,

Upendra

Using Web Services API:-

From the whole news feed, Is there any way to Follow/Unfollow a specific post?

  • January 20, 2012
  • Like
  • 0

Rest format for commenting is-

../chatter/feed-items/0D590000006SY64CAG/comments?text=my comment added successfully!

 

 

Above, Underlined portion is feeditemid, bold text is my comment.

 

But when i execute,

 

It gives error as -

[{"message":"The HTTP entity body is required, but this request has no entity bo
dy.","errorCode":"JSON_PARSER_ERROR"}]

 

There are methods-> setRequestHeader, setParams in HttpMethod interface,

but there is no method like "setEntityBody".

 

How to set the entity body in HttpMethod?

 

 

 

  • January 05, 2012
  • Like
  • 0

Hi,

I'm not sure if this is possible, but we have an idea to use chatter as a "help forum" for one of our apps. The goal is to have a help icon that links to the user's Chatter page - with the post area pre-pended with a hashtag and the app name.

 

Is this possible to do via a URL? Or is the only way with a Rest call to the API?

 

Thanks,

Walt 

  • December 21, 2011
  • Like
  • 0

I am trying to understand chatter Rest api from months, I have only understood the flow.

Before coding in any new language, we understand the primitive data types, simple hello world example, use of methods, return types etc.

I am good at Java.

My question is to how to use classes of chatter REST api in Java.

Rest api returns information in JSON/XML format, but how to store such a format in Java made grasping difficult for me.

 

I have already referred salesforce chatter api documentatn a lot, but i found it complete but at very top level( i.e- they have only given classes and code snippets to follow,post,delete etc)

 

Where can i get an easy tutorial for implementing chatter rest api applications in Java from scratch??

 

 

 

  • December 15, 2011
  • Like
  • 0

I am trying to post to the Chatter Rest API using the request body instead of a request parameter. This is what my code looks like:

 

HttpRequest req = new HttpRequest();
  
req.setEndpoint('https://na12.salesforce.com/services/data/v23.0/chatter/feeds/news/me/feed-items');
req.setMethod('POST');
req.setHeader('Authorization', 'OAuth ' + userInfo.getSessionId());
req.setHeader('Content-Type:', 'application/json');
req.setBody('{ "body" : { "messageSegments" : [{ "type": "Text","text" : "foo bar"}]}}');

Now according to this documentation, if I define the content type as application/x-www-form-urlencoded, it will be looking at the request parameters for the "text" field. However, since I'm defining the content type as application/json, it will be looking at the request body for all the info.

 

So why is it ignoring the body and telling me that I need to use the "text" field in the request parameters?

Hi,

I am playing around with Google oAuth playground.I got success in HTTP GET,HTTP DELETE,HTTP POST requests.But when I tried HTTP PUT it was throwing me below error.

 

"{
"message" : "HTTP Method 'PUT' not allowed. Allowed are HEAD,GET,PATCH,DELETE",
"errorCode" : "METHOD_NOT_ALLOWED"
}"

 

Kindly let me know how can I update salesforce records?

 

Thanks,

Hi there! Is there a way to restrict a user from following another user? I believe there is no existing functionality to achieve this. But is there a way to achieve this via custom coding? Can you please provide any references or guide me how i can do this?

I am trying to upload a PDF file to a Chatter feed in my Java web application.
It works fine with v25.0, but when i try to use v27.0 it does not work anymore and response status code is 500 - Internal Server error?

 

I'm using the example code from Chatter REST API page number 138:
http://www.salesforce.com/us/developer/docs/chatterapi/salesforce_chatter_rest_api.pdf

Any ideas to work this around?

Hi All,

 

I am sharing a feed-item using below REST URI:-

 

/services/data/v26.0/chatter/feeds/user-profile/me/feed-items?originalFeedItemId=<originalFeedItemId>&text=<shareComment>

 

It is posting a new feed as share, but its not creating any comment on new feed.

 

Any help is highly appreciated!!

 

Thanks!

Can we add a flag(boolean field) to Chatter posts so that we can do some calculations/DML for such feeds when they are inserted?

What kind, if any, limitations are set for Chatter External Users when using the REST API?

So we have pre-existing groups and users but I have been asked that all posts in chatter be emailed to all the group members right away and not just in the daily digest.  I've changed the setting in the groups from daily digest to email all posts but for some of these preexisting groups it still saves it for the daily digest.

 

Is their away to set all groups and users to these settings?

 

Thanks for your help. 

 

- Eric Gins

  • February 06, 2013
  • Like
  • 0

Hi ,

 

Do we have any way in APEX, to know the relationship that is shown on chatter via "Originally Posted By". I can see the share post as a FeedItem but no clues where it stores the linkage to original feed. I am open to APEX/SOAP/REST API or any other way.

  • February 04, 2013
  • Like
  • 0

It would be very helpful if people can post in chatter with pre-defined template.  For example,  define a milk feeding template for childcare.  They just need to input 3 ml in the template and the chatter post would be " Little Jack had 3 ml milk at 2 pm".   It will be a lot easier for people using phone or pad. 

 

Is there any way to make this happen? 

Any suggestion would be highly appreciated.

 

Thanks

 

Hi,

    Can someone expalin what community in salesforce chatter api means and its use.

Hi everybody

I got a problem, trying to upload a picture profile photo, So I've been trying to do this in may ways, apperently you cannot do this with a simple query, you have to do this by the Chatter REST API, So here I got my problem, I'm trying to upload this by two ways.

- One, with javascript, calling background the Chatter REST API

- two, with the "ConnectApi" APi, it should work, but there is no way. I got this problem.

 

Error: TestController Compile Error: Dependent class is invalid and needs recompilation: ConnectApi.feeditempage: line 8, column 25: Dependent class is invalid and needs recompilation: ConnectApi.feeditem: line 6, column 20: Dependent class is invalid and needs recompilation: ConnectApi.actor: line 38, column 15: Dependent class is invalid and needs recompilation: ConnectApi.unauthenticateduser: line 2, column 50: Invalid class: actor at line 3 column 9

 

Can someone help me how to solve this ? Or maybe tell me how to do this task without using chatter rest API

 

Hi,

 

I am new to Chatter development. I have the following usecase:

 

I need to post the response that I get from REST API call (Http request call out made to a Url ) to chatter.

 

Please suggest me the required documentation as well as approach to solve this use case.

 

Thanks in Advance.

I am not able to update name and title of a file uploaded in chatter using Chatter api. I am getting an error.

What is the structure of the json file which stores the fields desc and title for updation.

 

[{"message":"Missing expected \"fileData\" binary parameter","errorCode":"POST_BODY_PARSE_ERROR"}]

 

Plz reply.

I am trying to push a comment from my code into the Chatter instance for a user.  I have been able to use the SOAP API and the UserFeed object to get what comments are out there for my account but I am not sure how I can push a new comment out there from my application.  Do I have to use the REST API to do this?

Hi Everyone;

I need embed a flash rendition  /chatter/files/fileId/rendition in a visualforce page,

Someone knows, how can I do it?

Thank you

We're using the Chatter API and pulling a feed into our application.

 

We are retrieving the image URL from the Chatter API feed response and attempting to display it in the web app.  The detail from our HTTP XHR traffic analyzer is showing a 302 Found HTTP response but the following message is also showing and the profile photo of each user is missing,

 

Resource interpreted as Image but transferred with MIME type text/html: "https://na8.salesforce.com/content/session?url=https%3A%2F%2Fc.na8.content.force.com%2Fprofilephoto%2F729C0000000DXXXXX".

 

The login to the SFDC site/portal itself is timedout but we refresh the API token for the Chatter API calls and the photos don't show.

 

Can anyone offer an explanation for why this is happening? Or what the solution might be? 

When invoking the chatter REST API from a force.com page I get:

Origin
https://*.ap1.force.com is not allowed by Access-Control-Allow-Origin.

 

How do I add my force.com site to the allow list?

 

Basil Rakawi