[SalesForce] Consuming Salesforce REST API using SoapUI

Can we use SoapUI to invoke Salesforce REST API? If so, please let me know how to do that. I have tried but getting error "Invalid Session Id".

Thanks.

Best Answer

You can test REST API through Soap UI tool.

Before setting up a REST call to request a token in SoapUI, make sure you have an Connected App Created in the Salesforce Org and have latest version of SoapUI installed.

If you are new to Connected App, please find the details here.

  1. Create a Connected App

  2. Setup a Salesforce Connected Application

Steps to make the REST Call.

Step 1 - Set up a REST call to request a token in SoapUI

  1. In SoapUI Click File | New REST Project
  2. For the URL, enter "https://login.salesforce.com"
  3. In the top-left corner, change the method to POST from the default GET
  4. In the "Resource" section to the right of the Endpoint, enter, "/services/oauth2/token"
  5. Add these request parameters client_id = Consumer Key From Connected App , client_secret = Consumer Secret From Connected App, username = Salesforce Username , password = Salesforce Password and grant_type = password. The default value for the grant_type is password.
  6. Click Run. The output displays your access token to be used in future REST calls. enter image description here

Step 2 - Set up a REST call to request the REST API

Here I am using Salesforce default REST API (/services/data/v41.0/sobjects/Account/{Account Id}) to get the Account details.

  1. In the same project created above, right click and click "New REST Service From URI"
  2. For the URL, enter the URL received in the attribute "instance_url" from the earlier request (Step 1).
  3. In the "Resource" section to the right of the Endpoint, enter, "/services/data/v41.0/sobjects/Account/001i000000Z8Tze" Or whatever your REST API URL.
  4. In the top-left corner, make sure the method is selected as GET as it is a GET call for me.
  5. Add the "Authorization" header as Authorization: Bearer . Make sure there is a gap after "Bearer".
  6. Click Run. The output displays your Account Details.

enter image description here

Related Topic