Contents[Hide]

Main goal is to expose apex service to externall apllication which should call URL with paremeters and get back a file or error message

1. Just simple service inside salesforce

Service accepts two parameters Company and street.

Apaex class:

@RestResource(urlMapping='/RemoteActivation/*')
global class as_remoteActivation {
    #http://wiki.developerforce.com/page/Creating_REST_APIs_using_Apex_REST
    @HttpPost  
    global static String genrateLicense(RestRequest req, RestResponse res) {

        System.debug('COMPANY: ' + company);
        System.debug('STREET: ' + street);
        return 'Done';
    }
}

Main path for apex services is: https://cs8.salesforce.com/services/apexrest/ where cs8 is your server name.
So comlete call will look like that:

https://cs8.salesforce.com/services/apexrest/RemoteActivation?company=abc&street=xyz

2. Setting up OAuth authorization

Admisitrator shpuld configure remote accest as shown here section Setting up a Remote Access Application
External app should follow with this manual.

The two primary endpoints used with OAuth 2.0 are:
Authorization - https://login.salesforce.com/services/oauth2/authorize
Token - https://login.salesforce.com/services/oauth2/token

Sources:

REST
http://wiki.developerforce.com/page/Creating_REST_APIs_using_Apex_REST - basics, first document to read
http://wiki.developerforce.com/page/Getting_Started_with_the_Force.com_REST_API
http://www.salesforce.com/us/developer/docs/api_rest/
http://blog.cloudspokes.com/2011/07/building-apis-with-salesforcecom-apex.html
a

OAuth
http://wiki.developerforce.com/page/Using_OAuth_to_Authorize_External_Applications how to login from external app
http://wiki.developerforce.com/page/Digging_Deeper_into_OAuth_2.0_on_Force.com auth URL structure
OAuth 2.0 Username-Password Flow
a

   
© Paweł Woźniak