Hello, I am new to Postman and APIs in general. I am sending a Get request and I am trying to filter the data results I get back. Do I have to run a pre-request script to catch the results array and then filter or is there another way?
I guess another way to ask this is the Get request gives me an array of information, how do I access the array to filter down to the ones I am looking for?
I messed around with the “Params”, the “Body”, and the “Tests” tabs but none really gave me what I was looking for.
This is basic functionality and is covered in the training.
If you are new to Postman. I would recommend going through the Postman training if you haven’t done so yet.
Postman Galaxy Training | Postman API Network
Run through the “APIs 101 Training”, then the “Testing and Automation Training” course.
You also need to explain what you mean by filter.
If you want to filter when you submit the request (using params) then this is reliant on the API supporting this method.
If you are talking about filtering the response to retrieve a specific element from the response, then this is covered in the training. (It’s done in the tests tab, which runs after the response is received).
You can have a look at this topic, for an example.
Using ‘For loop’ to find the exact data - Help - Postman
Thank you for the training, it was helpful, but I am still running into the problem that lead me to ask the question in the first place. Specifically in the training, when I add the Param for admin and put in my email, I still get the “customers” that were created by postman and not me. A similar thing happens with my initial data. Is this just a thing happening to me or am I not understanding how the Params are supposed to work?
The params are API and request specific.
They only work if the API supports the particular parameter.
Are you talking about the “Get Customers” request in the “Galaxy APIs 101” training?
When you set that to individual, it won’t just return the one you created (which is also individual).
Change it to organization, as that should only return one record. (So you can see the filter in action).
As mentioned previously, you can only filter using parameters if the API supports that action.