Postman has been an amazing tool for me, but I have some questions about using variables. In my collection I have 4 tabs/requests.
The first is to get a token that is used in the other three (the token expires after 15 minutes so I have to rerun that request frequently and update the other 3). It needs to be passed in the headers of the other three requests. I'm familiar with the {{variable}} syntax, but I'm not sure how to dynamically set the variable after running the first request.
The second is similar, where I'd like to be able to set a string manually in some central location and use it in all of the requests. For instance, the URL is https://the.api.com/v1/{{someidvalue}}/abc so where can I change that in a single location manually to be reused across the collection?
Thank you!
To change the value based on server response you can use the test feature Postman test script
For exemple
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("Authorization","Bearer " + jsonData.result.accessToken);
The central location that you are looking for is the enviroment postman manage environments
Related
So here is my case, I am trying to implement concurrency test using jMeter with over 100 users. I got the foundation set up. However, the challenge I am encountering is that I have two APIs on postman one which I need to get accident case as UIID that is the first API and the second API is an API in which I register the accident. Each accident api requires different accident case. In other words, all 100 users will have different accident case. I usually do that manually when manual test but how do I do that automated in jMeter
enter image description here
Thank you and best regards
You can use __UUID
"accidentCase": "${__UUID()}",
The UUID function returns a pseudo random type 4 Universally Unique IDentifier (UUID).
If you're getting an accident case in 1st request and need to use it in 2nd request you can extract it from the 1st request response using a suitable JMeter Post-Processor and save it into a JMeter Variable
Then in 2nd request you need to replace the 21d2a592-f883-45f7-a1c4-9f55413f01b9 with the JMeter Variable holding the UUID from the first request.
The process is known as correlation and there is a lot of information on it in the Internet.
I have created a postman collection consisting of around 80-100 requests. And I have categorized them in 5 separate folders. Each folder has its own functionality.
I want the multiple pre-request scripts to be run sequentially for the specific request. What is currently happening is the number of scripts I have in one post-script is running but not in sequence. It runs randomly or not sure how. I would appreciate any help.
Pre Request script execute per request (if its in request) or once for all the reqeusts in the collection if its collection level . You cannot control the flow of pre-request script alone., but you can control what request osend nex use postman.setNextRequest
https://learning.postman.com/docs/running-collections/building-workflows/
This will run pre-reqeust script of that particular request plus send taht request
I am really new to datapower gateway scripts & i have small requirement.
In datapower newly Gateway script is added from firmware 7.0 onwards. now i am trying to using the GWSript to develop the code to know the domain name and it's state.
here the input is a export.xml file. from that file i need to capture the domain and state of domains and need to be display as a HTML table.
output
If you have any idea about this. Please advise.
You can get the name of the domain from a service variable:
http://www-01.ibm.com/support/knowledgecenter/SS9H2Y_7.2.0/com.ibm.dp.doc/var-service-domain-name_reference.html
Not sure what you mean by 'state' but perhaps this is helpful:
You could interrogate the var://service/system/status/DomainStatus variable
http://www-01.ibm.com/support/knowledgecenter/SS9H2Y_7.2.0/com.ibm.dp.doc/var-service-system-status_reference.html
GatewayScript to get the variables:
var sm = require ('service-metadata');
var domain = sm.getVar('var://service/domain-name');
var domainState = sm.getVar('var://service/system/status/DomainStatus');
In the web app I am testing, a unique authorization code is generated at runtime and submitted with each http request during that [web browser] session. Jmeter script recorder stores the hardcoded value, which again is only valid during that session.
I can use the Regular Expression Extractor to capture the authorization code, which is generated on the 10th http request in the test plan. I need to tell JMETER to use this new authorization code in all subsequent http requests in the test. I can manually replace all subsequent occurrences of the code with the new value extracted, but this would mean hundreds of manual changes.
Is there any way to tell JMETER that from a given point going forward, ignore the hardcoded value and use the value extracted during the 10th call. This is important because each test plan has hundreds of calls and there will be multiple test plans for the web site.
THX
Don't use hard-coded value as in runtime it will be quite hard to replace it. Use a JMeter Variable instead. Something like ${AUTH_CODE} wherever it is required.
Make sure that you use the same Reference Name AUTH_CODE in your Regular Expression Extractor at 10th request of your test plan.
If your Test Plan contains multiple thread groups use JMeter Property instead. See How to Use Variables in Different Thread Groups for step-by-step implementation guide
I am working on doing some simple analytics on a Django webstite (v1.4.1). Seeing as this data will be gathered on pretty much every server request, I figured the right way to do this would be with a piece of custom middleware.
One important metric for the site is how often given images are accessed. Since each image is its own object, I thought about using django-hitcount, but figured that was unnecessary for what I was trying to do. If it proves easier, I may use it though.
The current conundrum I face is that I don't want to query the database and look for a given object for every HttpRequest that occurs. Instead, I would like to wait until a successful response (indicated by an HttpResponse.status of 200 or whatever), and then query the server and update a hit field for the corresponding image. The reason the only way to access the path of the image is in process_request, while the only way to access the status code is in process_response.
So, what do I do? Is it as simple as creating a class variable that can hold the path and then lookup the file once the response code of 200 is returned, or should I just use django-hitcount?
Thanks for your help
Set up a cron task to parse your Apache/Nginx/whatever access logs on a regular basis, perhaps with something like pylogsparser.
You could use memcache to store the counters and then periodically persist them to the database. There are risks that memcache will evict the value before it's been persisted but this could be acceptable to you.
This article provides more information and highlights a risk arising when using hosted memcache with keys distributed over multiple servers. http://bjk5.com/post/36567537399/dangers-of-using-memcache-counters-for-a-b-tests