How to use object in postman params? - postman

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.

You should use JSON stringfy in order to save in the environment. after that use the Pre-request Script in order to add query params and JSON parse to get data from the environment. follow these steps as a sample code.
1- pm.environment.set("key", JSON.stringfy(object))
2- go to Pre-request Script
3- var data = JSON.parse(pm.environment.get("key"))
4- pm.request.url.addQueryParams([`param=${data.child}`])

environment variables are just text, so you might need to strigify the json response object and parse it before executing the next request.
There are pre-requests tests that you could use to read and parse the environment variable.
https://learning.postman.com/docs/writing-scripts/pre-request-scripts/#pre-request-scripting-example

Related

Not able to use regular expression extractor variable from one test plan to other test plan in jmeter

I am performing load testing using jmeter. I created a test plan with https request and used regular expression extractor to extract variable returned from first https request.
Variable: csrftoken
Regular Expression: value="(.*)"
Template: $1$
Match Number: 1
Default Value: EMPTY
2.Used JSR223 Postprocessor and verified that the extracted variable are correct.
log.info("***************************"+vars.get("csrftoken"));
I Created new test plan for signin request were I'm using the variable which was extracted in first test plan and defining the variable in parameters as
csrfmiddlewaretoken : ${csrftoken}
email : xxxxxxxx#gmail.com
password : Password
But ${csrftoken} variable are not getting picked up when I run the request.
Is there any other possible way to make use of variable from one test plan to other test plan and run the request with the same variable.
Help would be really appreciated!!
Thanks in advance.
What do you mean by "test plan", if you referring to this Test Plan and want to pass the value between 2 separate .jmx test scripts - the only way to do it is to write the CSRF token(s) into a file using i.e. Flexible File Writer in one test plan and read it back using CSV Data Set Config in another test plan
As per JMeter Documentation on variables, Variables are local to a thread to you cannot access a JMeter Variable anywhere but within the bounds of single thread (virtual user) context, you cannot even access it in the different Thread Group, not talking about different test plans.

How to reference other collections in postman

Is there a way to reference other collections from a specific collection. For example, if I have a file upload collection (something that uploads a file), I want to be able to use that from other collections. How would I reference the file upload?
Here's an example of what I'm talking about.
I have a collection where a file is uploaded and a calculation needs to be performed. The test or collection would go something like this where each step is a POST, GET, etc
Upload and run calculation:
Generate a token
make call
copy/save token value
Upload specific file (these would be 3 individual requests)
Upload file
Monitor upload status
Return ID of file uploaded
run calculation
use ID to pass as parameter
pass other values to set up calculation
monitor run
validate results
In another collection I need to validate uploaded files metadata is correct. Not directly related to the one above, but has some similarities
Generate a token
make call
copy/save token value
Upload specific file (these would be 3 individual requests)
Upload file
Monitor upload status
Get final result and return ID of file uploaded
Get me
validate metadata is correct.
Steps 1 and 2 are common functionality, there would be no difference there. How could I extract those two steps as modular components or functionality so I can reference them from any collection?
For additional clarity, we use ReadyAPI and are able to do 'Run Test Case' which can obviously run another test case. We've separated the functionality of token and file uploads into it's own test case and use it as a modular component. I'd like to achieve something similar with Postman.
Unfortunately Postman collections are working a little bit different.
But you can Merge your two collections to a single one, and execute it as one single collections.

Using Postman variables across tabs

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

How to pass csv data in postman collection so monitor can pick it

I have a situation where I have added my testdata in csv sheet. Moreover, I have created automated tests in js and I am passing this csv data with csv at the time of Collection Runner. It is working fine with postman on my local but when I run these testcases on postman monitor(https://monitor.getpostman.com/) these testcases is failing. Surely because of csv file unavailability. Is there any way I can pass my csv to monitor mode?
Unfortunately there is no such functionality in place right now. You can use csv files with collection runs and directly via the newman cli tool as described here.
You can file a feature request for this and look at the current product roadmap here.

JItterBit HTTP Endpoint

I am working to set up a HTTP Endpoint in JitterBit, for this end point we have a system that will call this Endpoint and pass parameters through the URL to it.
example...
http://[server]:[server port]/EndPoint?Id={SalesForecID}&Status={updated status in SF}
Would i need to use the Text File, JSON or XML Method for this? Follow up question would be if it is JSON or XML what would the file look like that is uploaded during creating the endpoint. I have tired with no success with the text file version.
any help would be great.
I'm just seeing your question now. You may have found a solution, but this took me a while to figure out, so I'll respond anyway.
To get the passed values, go ahead and create your HTTP Endpoint and add a new operation triggered by it. Then, in your new operation create a script with something like the following:
$SalesForceID = $jitterbit.networking.http.query.Id
$UpdatedStatus = $jitterbit.networking.http.query.Status
You can then use these variables elsewhere in your operation chain.
If you want to use these values to feed into another RESTful web service (i.e. an HTTP Source), you'll have to create a separate transformation operation with the HTTP Source. You'd set that source URL to be: http://mysfapp.com/call?Id=[SalesForceID]&Status=[UpdatedStatus]. I'm not sure why, but you can't have the script that extracts the parameters from the Endpoint and the HTTP Source that uses those in the same operation.
Cheers