To Login into Salesforce Org
Use user credentials below for Salesforce login.
- Sandbox URL : <<URL of the Salesforce Org>>
- Username : <<Username of the org credential> LPassword : <<Password of the User>>
- Security Token : <<Security token of the User>>
To Create Connected App
A Connected App is needed in Salesforce to authorize external systems using OAuth 2.0.
Please refer below URL for more details.
or follow-up below steps
- Switch over to Lightning Experience
- From the Setup -> quick find the “App Manager” and click on it
- Click “New Connected Apps” from the Top corner button.
- Fill in the required fields:
- Connected App Name: Enter a connected app name
- Contact Email: sample@gmail.com << give the desire credential>>
- Check the Enable OAuth Settings
- Call back URL: https://oauth.pstmn.io/v1/callback
- Selected OAuth Scope: select all the available option
- Click Save button
- Click Continue button
- Once created new connected app, you can get client Id and client Secret Id. Refer screen short
- Consumer Key: 3MVG9NYvTkhtdEI7DTI9FlgDxG04BVxJi2SI04QRWB8XjHLZdbxvGXZsnAkc2hsmOZpCw6Ogl4TJ3uVdOTUY6
- Consumer Secret: F9B4860783ECA84F27CD71362C06472D3B68A736CF225C4EEB016E13D28CAEE1
Once created new connected app, you can get client Id and client secret Id. As mentioned in screenshot
Connecting to Salesforce REST APIs Postman client
Below are the steps to authorize and test Salesforce REST API using Postman tool.
- Use the link https://www.postman.com/downloads/ to download the free postman tool.
To authorize Salesforce Org from Postman. Setting up the HTTP login request URL
- Launch Postman
- Create a new request. Use https://labelbox.my.salesforce.com/services/apexrest/SFOrganizationIntegrationService in the URL box for Sandbox connection.
- Choose POST method since it is a POST request to get access__token for Salesforce Org.
- Click the “Authorization” option and choose the “OAuth 2.0”
- Choose Add Authorization data to “Request Header”
- Fill in the details below “Configuration new Details”
- Token Name – Any suitable name (For example: SF Token)
- Grant Type – Authorization code
- Callback URL – Authorize using browser
- Auth URL - https://login.salesforce.com/services/oauth2/authorize (If you have custom domain enabled then provide custom domain URL https://sample.my.salesforce.com/services/oauth2/authorize)
- Access Token URL – https://sample.my.salesforce.com/services/oauth2/token
- Client Id – Your Client ID
- Client Secret – Your Client Secret
- Scope – Optional leave blank
- State – Optional
- Client Authentication – Select Send Client Authentication in body and click on Request token
- Click “Access Authorization”
- It will redirect to Salesforce login page.
- Provide Salesforce credentials and click allow
- Once access is completed, Authentication completed will show.
- Go to postman page and you can get popup window, click get “access token”
- Click “use token” from postman.
- A new token will appear.
GET Request: Test Custom Rest API using Postman to get Organization & Add-Ons details.
- Set HTTP Method should be “GET” and give the access URL https://sample.my.salesforce.com/services/apexrest/SFOrganizationGetAddOnService/<<OrgId> (custom domain should be your domain)
- Click Send button and the response is
Sample Output
{
“Tier”: “<<Name of the default entitlement record>>”,
“orgId”: “<<Organization Id>>”,
“message”: “Organization found in Salesforce.”,
“addOns”: [
{
“Quantity”: <<quantity number>>,
“addOnName”: “<<Add-On Name>>”
},
{
“Quantity”: <<quantity number>>,
“addOnName”: “<<Add-On Name>>”
},
{
“Quantity”: <<quantity number>>,
“addOnName”: “<<Add-On Name>>”
},
{
“Quantity”: <<quantity number>>,
“addOnName”: “<<Add-On Name>>”
}
]
}
POST Request: Test Custom Rest API using Postman to create Organization in Salesforce.
- Add Input JSON Payload as mentioned below.
- Check the raw and choose data type should be JSON
Sample Input request
{
”orgId” : ”<<Organization Id>>”,
”orgName” : ”<<Organization Name>>”,
”orgUserId” : ”<<Organization User Id>>”,
”orgUserEmail” : ”<<Organization User Email>>”
}
Sample Output response
{
”responseType”: ”success”,
”orgSFId”: ”<<SF Id of the Organization Record>>”,
”orgId”: ”<<Organization Id>>”,
”message”: ”Organization record created/updated successfully.”
}