Overview
Excerpt | ||
---|---|---|
| ||
Set up Salesforce User Creation API to allow a user to be created from the Salesforce contact screen. |
...
This User Creation API is called with a payload (transmitted data) of the user information including approval limits, customer associations etc, from the Salesforce contact screen. The web application will run validations and create the user after the validations are passed. An option in the payload is to specify whether a welcome email is to be sent to the user.
...
This is the primary data sent:
- First Name
- Surname
- Email Address
- Customer Code
- Account Administrator
If the user already exists, you will be alerted with a message.
...
This guide covers what you have to do in the process to set up the User Creation API. You will be provided with the necessary informationTo create code to retrieve the authorisation token and code to the API call endpoint, you will need the following:
- The ClientID and ClientSecret (will be provided to you)
- The Token api endpoint: /api/token
- The api endpoint: /api/
...
With this info, you need to create code to retrieve an authorisation token and code to the API call endpoints.
- user
Prerequisites
- URL (will be provided to you)
- Username
- Password
- Sample Setup Request file (see sample at the end of this page)
- API testing app / browser add-on:
- Postman (Chrome) - https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop?hl=en
- Poster (Firefox) - https://addons.mozilla.org/en-US/firefox/addon/poster/
Step-by-step guide
...
1. Get Authorisation Token
Before any API call is made, an authorisation token must be created.
1. Open Postman.
2. Enter the URL in the URL request box.
...
|
6. Do a call to get the token.
Tthe 'Authorization' uses the above auth value to generate the token:
|
7. The response is an object with two fields:
- response.token_type: this is the authorisation type that is needed for the api calls (should be 'bearer' usually)
- response.access_token: this is the actual token
Make the API call
The token_type and access_token are needed to make the API call. The API endpoint requires use of the token type and token in the authorisation header.
The API request content is the payload.
s
|
NOTE - The response object should contain a response that allows you to see whether the call succeeded and whatever response information the call will return. All responses should contain "Success" and may contain "Message" (it should have the field but might have no content depending on the service). All other fields on the response object are endpoint specific.
Example
Below is an simple example of combining the above into a function that retrieves a token and caches it in local storage. It also retrieves the token if it is not cached or if the api endpoint call returns a 401 (not authorized) because the token is expires:
...