Questions tagged [postman-testcase]

283 questions
13
votes
1 answer

Postman scripting: how to decode token

I'm using postman with scripting. First, I perform a request to retrieve a oauth token. Then, inside the 'Test' tab, I'm using postman scripting to use the received token to set a global (postman) variable. Additionally, I would like to decode the…
10
votes
1 answer

Is there a way to retrieve the redirected url from a Postman response?

I'm trying to submit a form in Postman which then redirects to another url. The redirected url query string contains some information that I want to use in my next call. Is this even possible and if yes, how? I haven't been able to find anything in…
user2865020
  • 218
  • 1
  • 3
  • 7
8
votes
3 answers

Postman : How to assert all array elements exist in other array?

I'm asserting for elements in array1 does exist in array2 or not, below are the array samples, var array1 = [ { "name": "appe", "loc": "war", "order": 5, "neck": "NO", "end": false …
Dev
  • 2,739
  • 2
  • 21
  • 34
7
votes
1 answer

Why Environment variable doesn't update in postman flow?

When I am calling an api with normal api calling in postman and running a test script and setting environment value, it's working but when I use that api in postman flow, environment doesn't changing. Script in my test: pm.environment.set('email',…
7
votes
1 answer

Check null value in Postman test cases .not.eql() or .not.equal() are not working

I'm working with a API project and using Postman for testing APIs. I wrote few test cases to check null as follows, //user id is present pm.test("user id is present", function() { pm.expect(jsonData.data[0].userId).not.eql(null); }); Also tried…
Divyang Desai
  • 7,483
  • 13
  • 50
  • 76
6
votes
5 answers

postman pm set environment variable

I will get the JWT token as response i need to set that JWT token as environment variable in postman this is my code pm.test("access_token is working", function () { var jsonData =…
Jeevan
  • 83
  • 1
  • 1
  • 9
5
votes
1 answer

Postman getting random UserName inside Pre-Request Scripts

I'm wanting to generate a random user to be created using the API, every time I run the request. I have an email environment variable which I want to be set to a random email every time the user create request is sent. I currently…
5
votes
1 answer

Postman conditional tests if json body array is empty = skip tests

I want to integrate Postman/ Newman API tests into CICD, so the test results should always be passed (or skipped). Therefor I want to use conditional tests, dependent on the data of the response. I tried the method described on GitHub, but the…
Zeno
  • 53
  • 1
  • 1
  • 3
4
votes
0 answers

Can postman automatically open a new browser window after response?

Example: I'd made a request and got response from the API. Response as below "status": "SUCCESS" "redirect_url": "https://www.google.com.tw/" I need redirect_url automatically open with a new browser window without click. Does anyone know how to do…
JYUN J
  • 41
  • 1
  • 2
4
votes
2 answers

How to get the status of test(i.e. pass or fail or error) in Postman?

Here is my test case in postman pm.test("verify the JSON object keys for machines - ", function() { if (Object.keys(data).length === 0) { pm.expect(Object.keys(data).length).to.eq(0); } } Now if status of this test is PASS then I…
Dev
  • 2,739
  • 2
  • 21
  • 34
4
votes
2 answers

Postman test to find a keyword in a response array

I am creating a test in postman to check for a keyword "pregnancy" in each "name" field in the JSON. If each 'name' field in the JSON contains the keyword then pass the test, else fail. Find the script below that I have tried using var jsonData =…
4
votes
0 answers

Postman to open browser and fetch data from website into request parameter

Is it possible for postman(App not Chrome extension) scripts to open an external browser and fetch data from the website (In my case a Temp Pin) as a request parameter? I did search on the web and didn't found any leads except that POSTMAN now…
3
votes
2 answers

How to use object in postman params?

I got a response from a get request as an object and added it to an environment variable. now I want to use it in another request params but I don't know how to do it.
sarem eskandary
  • 504
  • 4
  • 16
3
votes
0 answers

Postman: How to attach file in Formdata with Content Disposition

I got following to run from postman POST https://bonga.partner.com/api/v1/users/:user_id/image Payload is multipart/form-data with name="image[file]" Content-Disposition: form-data; name="image[file]"; filename="FILENAME" Content-Type:…
3
votes
2 answers

Customise Status codes in place of 500: Internal Server Error in FastAPI using Postman

I'm very new in using FastAPI and postman. When I am sending a POST request with a body (input data), I'm getting Success code 200 and also intended Response. Now, I want to tweak my input data to make my code fail intentionally. This is also…
mufassir
  • 406
  • 5
  • 16
1
2 3
18 19