How to test salesforce webservice with postman ?


While working on restful webservice, i have come across lot of them showing concerns about how to test the webservice apart from workbench. Workbench makes it easier to test the functionality for a salesforce developer, but while working with other team and integrating with external system we would need a much robust testing platform which is solved by Postman. Postman is widely used platform to test multiple platform, its best known for its option in authorisation which makes it compatible with multiple platform.

I shall share how to test a custom webservice which is build on salesforce and how we can test with Postman.


1. Create Connected App

Many people ask why do we need a connected app ? 

Connected App is simply an authentication and permission endpoint which can be set on salesforce. External system/application is authenticated using connected app giving a flexibility to set and revoke permission to app when necessary. 

From connected app following are the details required. 

> Consumer Key
> Consumer Secret


2. Create URL to Fetch AccessToken

Depending on the instance you want to test change the domain accordingly. With below URL as reference

https://login.salesforce.com/services/oauth2/token

Append the following to the URL, grand type, client secret and Id along with your salesforce username and password(Including security token).



3. If Auth is Successful your response will be like

Example:

{
    "access_token": "0DRNi1kILuiJVbhJOa3Xq9pG7GfI9vCD6nXWJTUJGfBpWCSAjxB_OblpCxlxB0ZtS",
    "instance_url": "https://login.salesforce.com",
    "id": "https://login.salesforce.com/id/000000L9YKMA0/0007R7pKQAS",
    "token_type": "Bearer",
    "issued_at": "1500358378108",
    "signature": "8KrzeR0zSSNN1xityu+8EsvPccSQPI="
}


4. Initiate Request



Once we have the Authorization Code we need to hit the POST Url with the access token and Json passed on header and Body. Your response from salesforce will be shown on the response section of Postman.

Try it out and reach out if you have any issue ! Enjoy !



Latest
Previous
Next Post »