Is there a c# wrapper available for the Salesforce REST Api?

18,420

Solution 1

A .NET tool kit was announced by salesforce.

"The Force.com Toolkit for .NET provides an easy way for .NET developers to interact with the Force.com REST API using a native libraries."

https://github.com/developerforce/Force.com-Toolkit-for-NET/

Solution 2

If you're looking for a Salesforce's REST API client library, take a look on SalesforceSharp.

It supports create, update, delete and query records from REST API.

Create

client.Create("Account", 
   new { Name = "name created", Description = "description created" }));

Update

client.Update("Account", "<record id>", 
   new { Description = "description updated" }));

Delete

client.Delete("Account", "<ID">);

Query

var records = client.Query<Account>("SELECT id, name, description FROM Account");

Nowadays it supports username-password authentication flow, but others flows (web server and user-agent) can be created and injected.

Solution 3

I was really hoping for something that would parse the WebResponse into classes representing the SF resources returned, and have solid error handling - the tedious stuff :)

This exists - it's called the SOAP API :) Seriously though, if you are doing server-side integration and want typed generated classes and solid error handling, SOAP is your pony.

Solution 4

I use RestSharp to simplify the calls and de-serialize the objects, but you still have to handle all the Salesforce error codes. It has some OAuth functionality built in as well, but the version I'm using (about 2 months old) doesn't support OAuth 2 very well. It's still a pain, but worth it if you are pulling a lot of data.

Solution 5

well, not that I know of. Nothing much to it though, depending on whether you want to use it client side or server side you use javascript approach (as documented in restapi) or simply System.Net.WebRequest for server side.

Check Dan's .NET blog

Share:
18,420

Related videos on Youtube

GC.
Author by

GC.

I develop software at OVO

Updated on June 28, 2022

Comments

  • GC.
    GC. almost 2 years

    I would like to integrate SalesForce information into a .net MVC application.

    The samples on SalesForce website are all SOAP as far as I can see, or alternatively there is a SalesForce ADO.NET data provider.

    http://wiki.developerforce.com/page/Web_Services_API#.NET

    Thanks.

  • GC.
    GC. about 12 years
    Thanks for the answer. I'll be using it server side to integrate into other systems. I was really hoping for something that would parse the WebResponse into classes representing the SF resources returned, and have solid error handling - the tedious stuff :)
  • mmix
    mmix about 12 years
    if you want strong typing you should go the WSDL way and use web services. REST by itself is an architectural idea rather than a set protocol that could lead to universal code generation, it doesn't even mandate the use of JSON which sf restApi uses and it does not include any standardized metadata that you could parse and create classes. In theory you can use /sobjects/object_name/describe to retrieve the metadata as aprt of development proces, then create classes for it and use JavaScriptSerializer.Deserialize<T>. HOwever, it sounds and really is a pain :)
  • GC.
    GC. about 12 years
    Interesting, I will take a look at RestSharp. I was looking at the asp.net web api samples where they extend to access twitter via OAuth2: code.msdn.microsoft.com/Extending-HttpClient-with-8739f267
  • Walter
    Walter about 12 years
    Thanks for the link, I'll definitely check that out. Is that sample for OAuth2 though? I haven't looked at it closely, but I noticed the oauth_ prefix, which is not implemented in the Salesforce OAuth2 service.