DX, API Design & Documentation

A Dynamic Salesforce REST API Postman Collection Builder Collection

32views

I have been working on developing new ways to make the Salesforce API more accessible and easier to onboard with over the last couple of months, helping reduce friction every time I have to pick up the platform in my work. One of the next steps in this work is to develop a prototype for generating a dynamic Postman collection for the Salesforce REST API. I had created a Postman collection for the API earlier, but the Salesforce team pointed out to me that the available APIs will vary from not only version to version, but also user account to user account. With this in mind I wanted to develop a tool for dynamically generating a Postman collection for the Salesforce API, and as I got to work building it I realized that I should probably just make the tool a Postman collection itself (mind blown).

To help make on-boarding with the Salesforce API easier I created a Postman collection that uses the Salesforce API to autogenerate the Postman collection based upon the available objects and endpoints for the Salesforce REST API. The Postman collection has three requests within the collection to accomplish the creation of a dynamic collection. The first request pulls all the latest versions for the Salesforce API, using the Salesforce API.

Once I have the version of the Salesforce API I am targeting for a build I add it to the Postman environment I am using to define the operations of my Postman collection, and then I pull the list of available objects for this version, and for my own Salesforce account.

The objects that exist will vary for each Salesforce account, as well as version, making it pretty critical that that any Postman collection is dynamic, being generated from this personalized list of objects. The next request in our Salesforce Postman collection builder is the build, which generates individual requests for all of the available objects. After you run, the response just shows the list of available objects, but the test script for the request loops through each object and generates a set of requests from the derived values.

After the build request is sent, it will take 30-60 seconds for things to build, but once it does you should see a new folder called “Generated Requests” that has over a 1000 individual API requests in it organized by folders for each object. Providing a complete Postman collection for the entire surface area of the Salesforce REST API.

To use the Salesforce Postman collection builder collection you will need to setup an OAuth application in your own Salesforce account, and add the settings to the authorization for your Postman collection.

You will also need a Postman environment with your base URL for your Salesforce instance, as well as the version you wish to use, and the API key for your Postman account, which you can find under your account settings.

{
id: cfd883f0-9232-4fc8-a7fb-18003d537e8d,
name: Salesforce REST,
values: [
{
key: host,
value: [your salesforce instance host],
enabled: true
},
{
key: version,
value: [the salesforce api version],
enabled: true
},
{
key: postman_api_key,
value: [your postman api key],
enabled: true
}
],
_postman_variable_scope: environment,
_postman_exported_at: 2020-01-07T00:20:04.711Z,
_postman_exported_using: Postman/7.14.0
}

I have published the Salesforce REST API Postman collection builder to GitHub, as well as the environment I use. If you have any questions feel free to submit an issue there, and I’ll see what I can do. This is all just a proof of concept, and I am still determining what the road map for this Salesforce API Postman collection builder will be. So if you have any needs, I’d love to hear them.

This article originally appeared here.

Kin Lane
Kin Lane is a writer, storyteller, and recovering technologists. Kin is the Chief Evangelist at Postman, and is helping share the story of how Postman is the next generation of API development environment (ADE), while also continuing to tell API stories on API Evangelist about what is happening across the API sector.

APIdays | Events | News | Intelligence

Attend APIdays conferences

The Worlds leading API Conferences
with 9 Conferences in 2019:

Singapore, Zurich, Helsinki, Amsterdam, San Francisco, Sydney, Barcelona, London, Paris.

Get the API Landscape

The essential 450 companies

Get the API Landscape
Industry Reports

Download our free reports

The State Of Api Documentation: 2017 Edition
  • State of API Documentation
  • The State of Banking APIs
  • GraphQL: all your queries answered
  • APIE Serverless Architecture