Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to override the service end point for allowing the use of ... #1

Merged
merged 1 commit into from
Nov 30, 2013

Conversation

RokitSalad
Copy link
Contributor

...custom rest services for specific entities. The one gocha is that any errors returned from the custom service must be formatted in a similar fashion as the standard rest end points.

…of custom rest services for specific entities. The one gocha is that any errors returned from the custom service must be formatted in a similar fashion as the standard rest end points.
@giacomelli
Copy link
Owner

Can you provide me a sample using an alternative url? I would like to improve the documentation with this sample.

Thanks!

@RokitSalad
Copy link
Contributor Author

Sure.

For example, when creating a new user, your SalesforceClient.Create method would be called as:

    _client.Create("CW_User", new { Username = username, ContactId = _contactId, Email = "a@a.com", FederationId = Guid.NewGuid() }, "services/apexrest");

where CW_User is a custom entity exposed at a restful endpoint of /services/apexrest/CW_User

With the change I made, any of the Create, Update, Query or FindById methods will accept an alternative url as an optional final parameter. SalesForce allows custom REST services to be exposed so further business logic can be abstracted away. The change allows the normal end point to be used when an alternative url isn't specified but be overridden when a custom end point is needed.

    private SalesforceClient _client;
    public void CreateContactWithCustomUser(string firstName, string lastName)
    {
        string contactId = _client.Create("Contact", new { FirstName = firstName, LastName = lastName });
        _client.Create("CW_User", new { Username = username, ContactId = contactId, Email = "a@a.com", FederationId = Guid.NewGuid() }, "services/apexrest");
    }

In this example, a contact is created as normal but the user is created at the end point services/apexrest/CW_User. The service exposed at this point has been written to implement some custom logic that isn't provided by the standard /User REST service.

Hope that helps :)

@giacomelli
Copy link
Owner

Ok, great new feature.
Tks!

giacomelli added a commit that referenced this pull request Nov 30, 2013
Added ability to override the service end point for allowing the use of ...
@giacomelli giacomelli merged commit b0449bf into giacomelli:master Nov 30, 2013
@giacomelli
Copy link
Owner

Added a FAQ question linking for your explanation: https://github.com/giacomelli/SalesforceSharp/wiki/FAQ
;)

@RokitSalad
Copy link
Contributor Author

Cheers :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants