CloudSole Salesforce REST Feed

I was looking at building a easy way to POST information from your salesforce org to my Public Feed. This feed can be used to publish and data from you salesforce org to the public.

Below is some code sameples on ways to POST to the Public Feed:


curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"name": "I love Cloudsole Salesforce Feed", "message": "This is awesome I can post my message on the public feed"}'

Apex code:


Make sure to add to you Remote Site Details.


public with sharing class HttpCalloutToFeed 
  public static void sentMessageToFeed()
    Http http = new Http();
    HttpRequest httpreq = new HttpRequest(); 
    String message = '{"name": "Message from ' + UserInfo.getFirstName() + '", "message": "My Organization ' + UserInfo.getOrganizationName() + ' located in ' + UserInfo.getLocale() + ' loves CloudSole public feed"}';
    httpreq.setHeader('Accept', 'application/json');
    httpreq.setHeader('Content-type', 'application/json');
    HttpResponse response = http.send(httpreq); 

Java code:

package com.thysmichels.main;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;

public class CloudSoleFeedMain 
    public static void main(String[] args) 
        HttpClient client = new DefaultHttpClient();
        HttpPost post = new HttpPost("");

            post.setEntity(new StringEntity("{\"name\": \"Message from Java Class\", \"message\": \"This is awesome I can post my message on the public feed\"}"));
            post.setHeader("Accept", "application/json");
            post.setHeader("Content-Type", "application/json");
            HttpResponse response = client.execute(post);
        } catch (IOException e) {

Leave a Comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s