Home
/
Stories
/
September 24, 2025
Salesforce

How to automate Salesforce API requests in Postman using the Describe API

How to use Postman with the Salesforce Describe API to automate request generation, simplify Salesforce REST API testing, and improve accuracy while saving time.
Salesforce API testing

Testing the Salesforce API can feel slow when you don’t know which fields are required to create a record. For example, do you need to include OwnerId when creating an Account? What about Name or other mandatory fields? Without clear guidance, you end up with failed calls and wasted time.

Instead of manually checking Salesforce API documentation each time, you can use Postman together with the Salesforce Metadata API to generate dynamic requests automatically. This method makes it much easier to test Salesforce objects, avoid missing fields, and speed up your workflow.

At Noltic, we work exclusively with Salesforce and have delivered more than 140 projects across industries. Our team of 93 certified experts, including 8 system architects, has deep experience with Salesforce API integration, automation, and Salesforce QA. The approach described below by our Senior QA Engineer Anton Derevyanchenko and is based on best practices our developers use to improve testing speed and reliability for client projects.

Understanding the Salesforce Describe API

Salesforce provides metadata for every object through the Salesforce Describe API. A simple REST call such as:

GET /services/data/vXX.X/sobjects/Account/describe

returns information about each field, including:

  • createable – if the field can be set on record creation;
  • nillable – if the field can be left empty;
  • defaultedOnCreate – if Salesforce fills the field automatically;
  • type – the field data type (string, date, picklist, etc.)

This metadata lets you know which fields are technically required when sending data to the Salesforce REST API. For instance, Accounts always need a Name, but OwnerId is set automatically.

Automating with Postman Pre-request Scripts

Postman includes a Pre-request Script feature that can run JavaScript before sending a request, so you can:

  1. Fetch metadata from the Salesforce Metadata API;
  2. Identify required fields based on their attributes;
  3. Generate sample values for each data type;
  4. Build a valid JSON payload automatically;
  5. Inject the payload into the request body.

This approach turns Postman into a lightweight Salesforce testing tool for automated payload creation.

Practical Implementation

Here’s a sample script that uses the Salesforce REST API describe call to dynamically build a request body:

javascript
const instanceUrl = pm.environment.get("sf_instance_url");
const apiVersion = pm.environment.get("sf_api_version") || "60.0";
const accessToken = pm.environment.get("sf_access_token");
const sobjectName = pm.environment.get("sf_sobject") || "Account";


const describeEndpoint = `${instanceUrl}/services/data/v${apiVersion}/sobjects/${sobjectName}/describe`;


pm.sendRequest({
    url: describeEndpoint,
    method: "GET",
    headers: { "Authorization": `Bearer ${accessToken}` }
}, (error, response) => {
    if (error) {
        console.error("Describe API call failed:", error);
        return;
    }
    const metadata = response.json();
    const requestBody = {};
    metadata.fields.forEach(field => {
        const isRequired = field.createable && !field.nillable &&
                          !field.defaultedOnCreate && !field.autoNumber;
        if (isRequired) {
            switch (field.type) {
                case "string":
                    if (field.name === "Name") {
                        requestBody[field.name] = "{{$randomCompanyName}}";
                    } else {
                        requestBody[field.name] = "{{$randomWord}}";
                    }
                    break;
                case "phone":
                    requestBody[field.name] = "{{$randomPhoneNumber}}";
                    break;
                case "email":
                    requestBody[field.name] = "{{$randomEmail}}";
                    break;
                case "date":
                    requestBody[field.name] = new Date().toISOString().split("T")[0];
                    break;
                case "datetime":
                    requestBody[field.name] = new Date().toISOString();
                    break;
                case "boolean":
                    requestBody[field.name] = true;
                    break;
                case "picklist":
                    if (field.picklistValues && field.picklistValues.length > 0) {
                        requestBody[field.name] = field.picklistValues[0].value;
                    }
                    break;
                case "reference":
                    if (field.name === "OwnerId" && pm.environment.get("sf_user_id")) {
                        requestBody[field.name] = pm.environment.get("sf_user_id");
                    }
                    break;
                default:
                    requestBody[field.name] = "{{$guid}}";
            }
        }
    });
    if (sobjectName === "Account" && !requestBody.Name) {
        requestBody.Name = "{{$randomCompanyName}}";
    }


    pm.request.body.update({
        mode: "raw",
        raw: JSON.stringify(requestBody, null, 2)
    });


    pm.request.headers.upsert({
        key: "Content - Type",
        value: "application/json"
    });
});

Configuration guide

To use this script:

  1. Set these environment variables in Postman:

sf_instance_url → your Salesforce instance URL
sf_api_version → the Salesforce API version (e.g., 60.0)
sf_access_token → valid access token
sf_sobject → object to test (e.g., Account)

  1. Create a POST request to:
    {{sf_instance_url}}/services/data/v{{sf_api_version}}/sobjects/{{sf_sobject}}
  2. Paste the script into the Pre-request Script tab
  3. Run the request – Postman will fetch metadata and generate the JSON body automatically.

Important considerations

While this approach significantly simplifies Salesforce test automation, remember that:

  • Technical requirements differ from business rules (validation rules, triggers, or flows might cause rejections);
  • Reference fields require actual Salesforce IDs;
  • Picklist fields need valid values from their specific ranges;
  • The script provides a foundation that you can extend based on particular object requirements.

Enhancing your Salesforce testing workflow

This dynamic method helps you:

  • Speed up Salesforce test automation across different objects
  • Reduce errors caused by missing or invalid fields
  • Adapt quickly when object schemas change
  • Improve consistency across multiple environments

While this doesn’t replace full Salesforce QA testing with proper Salesforce testing automation tools, it’s an excellent way for developers and Salesforce testers to validate APIs faster.

Start small with standard objects like Account and Contact, then expand to custom objects used in your org.

Conclusion

By using Postman with the Salesforce Metadata API, you can cut out repetitive trial-and-error when building payloads. This approach improves efficiency, reduces manual work, and supports better Salesforce automated testing practices.

If your team needs deeper support for Salesforce API integration or advanced test automation for Salesforce, consider working with certified experts. At Noltic, our team of 93 Salesforce specialists (including 8 system architects) has a proven record of delivering successful projects and a perfect 5.0 review score on Clutch. You can hire Salesforce developers from our team to speed up your integration and testing efforts.

FAQs

What is the Salesforce Describe API, and why is it important for testing?

The Salesforce Describe API is an endpoint within the Salesforce Metadata API that returns detailed information about objects and fields. For each field, it tells you whether it’s createable, nillable, or defaultedOnCreate, as well as its data type. This is critical when you test Salesforce APIs because it eliminates guesswork about which fields must be included in a request. For example, Accounts require a Name but not necessarily an OwnerId. By pulling this information programmatically, testers and developers can build valid payloads without constantly checking Salesforce API documentation.

How can I use Postman to test Salesforce REST API requests?

Postman is one of the most popular Salesforce testing tools because it lets you send API requests quickly and automate setup with environment variables. To test Salesforce with Postman, you typically:

  1. Authenticate using OAuth to obtain an access token.
  2. Set environment variables such as sf_instance_url, sf_api_version, and sf_access_token.
  3. Use endpoints from the Salesforce REST API documentation, such as /sobjects/Account/describe or /sobjects/Contact.
  4. Add Pre-request Scripts to dynamically generate request payloads based on metadata.

This setup helps with Salesforce QA testing and allows teams to validate both standard and custom objects before writing production code. You can learn more about REST API in Salesforce documentation.

What are Salesforce API limits and how do they affect automated testing?

Every Salesforce org has daily quotas for Salesforce API calls. These Salesforce API limits are based on your edition and license type. For example, Enterprise Edition provides 100,000 API calls per day, while Unlimited Edition offers 1,000,000. Calls to the Describe API and REST API Salesforce endpoints both count against this limit.

When running Salesforce test automation, frequent describe calls can consume your quota quickly. To avoid this, testers often cache metadata responses in Postman or other tools. Keeping API usage efficient is one of the best Salesforce testing best practices, ensuring that automated testing doesn’t interfere with production integrations.

What are the best automation tools for Salesforce testing?

Postman is excellent for API-level validation, but it’s not the only option. The best automation tool for Salesforce testing depends on your needs:

  • Postman – Great for testing the Salesforce REST API and quick validation of payloads.
  • Selenium – Often used for UI automation but requires more coding.
  • Provar – A specialized Salesforce test automation tool with native support for Salesforce features.
  • Testim / Copado / Tricentis – Platforms that provide low-code or no-code approaches for automated testing for Salesforce.

Many QA teams use a combination: Postman for API calls, Selenium for UI, and Provar or Copado for full workflow coverage. Choosing the best Salesforce test automation tools often comes down to budget, technical skill, and the complexity of your Salesforce org.

How do I automate Salesforce test cases with the Describe API?

You can build Salesforce automated testing workflows by combining the Describe API with Postman or similar tools:

  1. Call the Salesforce Describe API to get metadata for the object.
  2. Identify required fields programmatically.
  3. Generate dynamic test payloads with valid values for each field type.
  4. Send requests to the Salesforce REST API to create or update records.
  5. Validate the response to ensure that Salesforce accepts the request.

This method is a form of test automation for Salesforce because it removes manual setup. It also adapts automatically if object schemas change, which is critical for organizations that frequently add or update custom fields. Combined with other Salesforce testing automation tools, this creates a reliable and scalable testing framework.

Share:
Anton Derevyanchenko
Senior QA Engineer
Lord, grant me the serenity to delegate what cannot be automated, the courage to automate what can be automated, and the wisdom to always distinguish one from the other.
Oleksandra Petrenko
Content writer
Engaging and data-driven content creator focused on Salesforce solutions.
Let’s start a project together!
Change the way you do business with Salesforce.
Talk to us about Salesforce Field Service
Optimize scheduling, empower your team, and elevate customer experiences with Noltic’s Salesforce Field Service.
Letʼs work
together
Get in touch
moc.citlon@tcatnoc
Anton Derevyanchenko
Senior QA Engineer
https://www.linkedin.com/in/anton-d-a3ba1548/
Oleksandra Petrenko
Content writer
https://www.linkedin.com/in/aleksandra-petrenko23/
Oleksandra Petrenko is engaging and data-driven content creator focused on Salesforce solutions.
130+
delivered
projects
5.0
rating on
AppExchange
400+
Salesforce
certificates
8
Salesforce
certified architects