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
John BrumbelowJohn Brumbelow 

HOWTO Use REST with SFDC.

Please help.

We are a C#/.NET shop, and have been using SFDC with the WSDL api.
We want to use REST instead of the WSDL, where we would use C#/.NET code to call the SFDC-REST servers.
Can some one point us to simple, C#/.NET samples that accomplish the following tasks:

1) Create a SFDC object, using REST, given a C# string, that is in a JSON format for the object to create, and get back the
SFDC-ID after creating the SFDC object.

2) Same as (1) abiove, but create the SFDC object with a PDF, HTML-Text, and Binary File, set of attachments.

3) Update a SFDC object using REST, given a SFDC-ID.

4) Same as (3) but update the object to have new attachments, for a PDF, HTML-Text, and Binary File, set of attachments.

5) Same as (4), but in the update, remove any attachments.

6) Same as (4), but replace an existing attachment, given a file-name (or attachment name) to have something different.

7) Search for record(s) related to an SFDC object, given a SFDC-ID.

8) Search for record(s) related to an SFDC object, given key field information.

9) Same as (8), but using wild-card/partial search criteria, like search for all records where field X starts with "ABC", or
matches "A?B", or "A*B", etc.

 
Andrew FandreAndrew Fandre
I can give you a couple pointers. 
I just posted a question (https://developer.salesforce.com/forums/ForumsMain?id=9060G0000005rx7QAA)  with my code that does GET requests just fine, but I'm having trouble with the POST. In that question, a static method that populates the security params. It's not relevant for that code, but it can help you here.
 
public static HttpContent GetClientContent()
        {

            HttpContent content = new FormUrlEncodedContent(new Dictionary<string, string>
            {
                {"grant_type", "password" },
                {"client_id", ConfigurationManager.AppSettings["ConsumerKey"].ToString() },
                {"client_secret", ConfigurationManager.AppSettings["ConsumerSecret"].ToString() },
                {"username", ConfigurationManager.AppSettings.Get("username").ToString() },
                {"password", ConfigurationManager.AppSettings.Get("password").ToString() }
            });
            return content;
        }
The consumerKey and consumerSecret are values from the Connect App. The username and password are the service account we use.

As far as creating objects, I've just created them manually and populated them out return from the GET request. I can't help you with attachments as I don't use them.
John BrumbelowJohn Brumbelow
Thanks Andrew for the reply.
Is there any SFDC support personnel that could help?
 
Andrew FandreAndrew Fandre
I figured out how to work the POST request if you'll look at the answer for my question, you'll see that it required SendAsync rather than PostAsync.

As far as SFDC support, you should try help (http://help.salesforce.com) and submit a request. 

This documentation (https://developer.salesforce.com/page/Consuming_Force.com_SOAP_and_REST_Web_Services_from_.NET_Applications) you should already know about, it's been the main guide for my REST activites.