Using Postman and CSV data files to mass update Zuora data

Postman is the complete toolchain for API developers, used by more than 3 million developers and 30,000 companies worldwide. Postman makes working with APIs faster and easier by supporting developers at every stage of their workflow, and is available for Mac OS X, Windows, Linux and Chrome users. Best of all, it is free to use.

Postman’s Collection Runner is a powerful tool. As its name implies, the Collection Runner (CR) lets you run all requests inside a Postman collection one or more times. It also executes tests and generates reports so you can see how your API tests compare to previous runs.

There is a comprehensive blog post on how to create and use Postman and csv files here:

http://blog.getpostman.com/2014/10/28/using-csv-and-json-files-in-the-postman-collection-runner/

We'll bridge the gap between that blog post and how it applies to Zuora in the remainder of this blog post.

If you can use Zuora Connect, you can use Postman to do many of the same functions. Here are the high level steps that need to be completed:

  1. Create a Collection
  2. Create a Request
  3. Launch the Runner
  4. Create your CSV file with the headings the same name as the Zuora Request Body field names. Select the file from the Runner interface.
  5. Start the Runner
  6. Your request should complete successfully

Creating a Collection

Please view the following Postman Article: https://www.getpostman.com/docs/postman/collections/creating_collections

Creating the Request

To create the request, here is the Postman Article: https://www.getpostman.com/docs/postman/sending_api_requests/requests

1. Choose the Request Type, in this case PUT as we are updating Account fields

2. Enter your Server URL. In this example, we will mass update the Notes field on the Account so our Server URL is: https://rest.zuora.com/v1/accounts/{{Id}}

Zuora is particular and requires a path parameter. The path parameter can either be Account number or Account ID. In my example, I have chosen the Id.

The following are Notes from the Zuora Developer Docs:

  • Only the fields to be changed should be specified in the Request Body. Any field that's not included in the request body will not be changed.
  • If an empty field is submitted with this call, the corresponding field in the account is emptied.
  • Email addresses: If no email addresses are specified, no change is made to the email addresses on file or to the email delivery preference. If either the personalEmail or workEmail is specified (or both), the system updates the corresponding email address(es) on file and the email delivery preference is set to true. (In that case, emails go to the workEmail address, if it exists, or else the personalEmail.) On the other hand, if as a result of this call both of the email addresses for the account are empty, the email delivery preference is set to false.
  • The bill-to and sold-to contacts are separate data entities; updating either one does not update the other.

3. Choose the Authorization Type as Basic Auth, enter your username and password

4.  Enter the headers. I've chosen Key= Content-type | Value = application/json

5. Create the JSON Request Body

  • {
      "notes": "{{notes}}"
    }

6. Create the Pre-Request Scripts

  • console.log("Body contains Id" + data.Id);
    console.log("Body contains notes" + data.notes);

7. Create your Tests

  • tests["Body matches string"] = responseBody.has("true");

Launch the Runner

Once you click the Runner button at the top of the Postman UI, a new screen will launch called the Collection Runner'.

Fill out the details and upload your CSV file before clicking the Run button. Here is an article that explains all of the fields and variables:

https://www.getpostman.com/docs/postman/collection_runs/starting_a_collection_run

Once you click the blue 'Run' button at the bottom of the Runner screen, you should see the request results complete succeessfully:

A few last minute tips:

1. We were unable to get this to successfully complete with the web UI. We had to download the desktop app.

2. If you are having debugging issue, try viewing the console. It has helpful debugging details. You can access the console from the menu: view > Show Postman Console