Need to export dell warranty information from a CSV file

I have a CSV file with ~2000 Dell service tags that I’m trying to get warranty information from Dell’s asset-entitlements API & eventually post it into Service-Now. I am able to run the collection using the collection runner manually & get responses, but how do I save them to a file (CSV or JSON) and then import into Service-Now? It seems the collection runner saves the responses but when I look at the WarrantyInfo collection variable, it looks like it might be overwriting the previous responses since the warranty information is from the last entry in the initial CSV that I’m using in the runner.

This is what I have under Tests but I don’t really know what I’m doing :frowning:

const responseJson = pm.response.json();

requestName: ${request.name || request.url}-${Date.now()}

let response = pm.response.json(),
warrantyinfo = JSON.stringify(response);

pm.collectionVariables.set(“WarrantyInfo”, warrantyinfo);

Is there a way to save each response as it’s own variable (not overwriting the previous one) and which I could then use to import each one into Service-Now? TBH, I’m a little terrified to POST anything to Service-Now since I don’t want to put bad data up there & mess everything up.

Postman does not have direct access to the local filesystem to export results as CSV files.

There are a few workarounds available, which you can search the forum for, as the question has been asked a few times.

What info does ServiceNow require as you have a lot of info in that warranty variable, and I’m guessing that ServiceNow only needs some of it.

What you probably need is a folder with two requests in.

The first request should retrieve the warranty info for a particular device from the DELL portal.
The tests tab for that request should pull out the appropriate warranty info.
You would then save this info to a variable. This should be in the appropriate format for Service?Now. An object or similar.
The second request should post the selected warranty info to ServiceNow using the saved variable as the body.
Test it with one request\device until you get it working, before you try and loop through 2000 entries. (And don’t loop through 2000 entries straight away. Try 1, then 10, then 50, then 100 before you do large batches).

Do you not have a test instance of ServiceNow? I would have thought that you should have a PROD and TEST instance at a minimum so you can try these integrations out without fear of breaking production.

I’m not sure this is the correct tool for this type of task though.

Personally I would use PowerShell and invoke-webrequest. PowerShell can manipulate and loop though CSV files natively.

As you’ve mentioned you are not sure what you are doing, can I suggest a visit to the Postman Learning Centre in the first instance.

Overview | Postman Learning Center

Have a look at the Postman Training links in the Other Resources section.

Other resources | Postman Learning Center

I would recommend the “Galaxy APIs 101” course to start with as it gets you used to the client interface. Then the “Galaxy Testing and Automation” course which shows you how to write assertions and target elements in the response.

Some comments in relation to the code you did write.

const responseJson = pm.response.json(); // fine

requestName: ${request.name || request.url}-${Date.now()} // what is this doing?

let response = pm.response.json(), // you already did this on the first line
warrantyinfo = JSON.stringify(response); // why are you now turning the response back into a string?

pm.collectionVariables.set(“WarrantyInfo”, warrantyinfo); // are you sure you want all of the warranty info, or just the details that are needed by ServiceNow?