How to use data in csv file row wise to be used per request via newman? - api

I have bunch of requests in my postman collection for example :-
Request 1
Request 2
...
Request N
For each of these requests , I want to pass a client id for which is unique per request. I have created a data file with those client ids. So the data in CSV file is as follows : -
Client Id
1
2
..
N
My requirement is to use Client ID 1 in Request 1 , Client ID 2 in Request 2 instead of iterating Client ID 1 though the entire collection.
So basically data in CSV file to be used row wise in all the requests.
Would really appreciate suggestions on how this can be achieved.
I tried using Runner but it doesn't fit my requirement

Maybe it would be easier not to use .csv file here, but Postman Environment Variables.
If you're having the number of ClientIDs matches the number of request, you can do something like this:
In the Pre-Request Script of first request you have to initiate an array of clientIDs:
const clientIdArr = [1,2,3,4,5,6,7,8,9,10];
pm.environment.set('clientIdArr', clientIdArr);
Then we will shift the first value of array of clientID in every subsequent Postman Collection request:
const currentArr = pm.environment.get('clientIdArr');
const currentValue = currentArr.shift();
pm.environment.set('clientIdArr', currentArr);
pm.environment.set('currentClientId', currentValue);
Then you can use {{currentClientId}} environment variable in your actual request and exectute the Postman Collection via Collection Runner.
For more details how Array.prototype.shift() works please refer to the following link.
If you have a large amount of requests in your Postman Collection you might consider having those scripts as Postman Global Functions.

Related

In Jmeter, How to generate unique order and pass it in request body. The request body is been sent by CSV file

Im passing multiple request bodies for an API using RequestBody.CSV file.
This requestbody have orderID and it should be a UUID every time. I'm passing this OrderID using User Parameters
And replaced them in the CSV file like this
This is the CVS data set config used
When I run the test, the orderID is not generating random number and it is passed as
This is the HTTP request im sending
How can I send random orderID in the request body.
In your CSV file change ${orderID} to ${__UUID}, JMeter's __UUID() function generates an unique UUID v4 structure each time it's being called.
In the HTTP Request sampler change ${requestbody} to ${__eval(${requestbody})}, JMeter's __eval() function evaluates nested JMeter Functions or Variables so an unique UUID will be generated on each iteration of each virtual user
More information on JMeter Functions concept: Apache JMeter Functions - An Introduction

Include request parameters in URL when using Postman

I need to fire some requests using Postman but I need to include the parameter in the URL.
What I need:
https://serveraddress/v1/busride/user/favorites/route/RanDOMid
What I currently can configure in Postman:
https://serveraddress/v1/busride/user/favorites/route/?id=RanDOMid
I do not control the server, so I need to work it out how to craft the request in Postman to accept the input data as part of the URL, not as parameter. How can I specify input data in Postman to get it included in URL?
Click on Manage Environment
Add variable as path with Initial and current value as RanDOMid
Add path to URL:
https://serveraddress/v1/busride/user/favorites/route/{{path}}
#User7294900's answer should do for you in case all you want to do is include a variable in your request URL.
However, if you want to actually generate a random ID for every request, you may use {{$guid}} or {{$randomInt}} directly in you URL as follows:
https://serveraddress/v1/busride/user/favorites/route/{{$guid}}
This will generate a random GUID every time your request is fired and the generated GUID will replace {{$guid}} in your URL.
or
https://serveraddress/v1/busride/user/favorites/route/{{$randomInt}}
This will generate a random integer between 0 and 1000 every time your request is fired and the generated integer will replace {{$randomInt}} in your URL.
Refer postman documentation for more details - https://www.getpostman.com/docs/v6/postman/environments_and_globals/variables
Hope this helps!

How to pass parameters in post call in pentaho-spoon?

I have made an api and I want to access a post call in it. I made the following transformation in kettle:
with a params field in Generate Rows step as:
and REST Client step configuration as:
but I am unable to get any of the parameters in my post call on server side. If I write a simple post call in python as:
import requests
url = "http://10.131.70.73:5000/searchByLatest"
payload = {'search_query': 'donald trump', 'till_date': 'Tuesday, 7 June 2016 at 10:40'}
r = requests.post(url, params=payload)
print(r.text)
print(r.status_code)
I am able to get the parameters by request.args.get("search_query") on the client side in Flask. How can I make an equivalent POST call in kettle?
I found the solution myself eventually. Describe the fields in generate rows as:
and in the parameters tab in REST Client step, we should get the same fields:
Works perfect!

Use Response of a wcf request as request in another receive port

Is there any way to use the response of a wcf service method request as an input for the next request in same orchestration and return the response of the first request as well as the response of the second request as out put in BizTalk?
Eg :
My first request gives a response as "a"
Give this response "a" as request to the 2nd request and gets the response as "b"
Return the response as "a" and "b".
Is this possible?
Yes. You could either create a map from Response 1 to Request 2, and also create a multiple input message map from Response 1 and Response 2 to your final output message.
If the messages involved don't have any repeating structures, it may be enough to distinguish the fields that you need to be concerned with and just use a ConstructMessage with an XmlDocument, i.e.
// construct shape code
varXmlDoc = new System.Xml.XmlDocument();
varXmlDoc.LoadXml("<webSvcRequest2 xmlns=''><ParamB>" + msgWebSvcResp1.ParamA + "</ParamB></webSvcRequest2>");
msgWebSvcReq2 = varXmlDoc;
And similar code for producing the final output message. If you go this route, I'd advice creating some C# utility methods to actually store the strings/message templates.

Pentaho cookies with Rest Client Transformation entry

Is there an option to set cookies while using rest client in Pentaho 5.1?
I read a couple of blogs and it wasnt mentioned anywhere.
I have tried using curl using shell job entry. Got the cookie and used it in my next curl to get data.
I need to do a similar process using rest client transformation entry.
Please let me know if there are any leads I can follow.
i dont know if you can do that with this step, but with the http client step you can set you own http request headers. This works because i use this way.
if you can use the http client step instead the rest client do this:
add a new Script step (the javascript step) and add this js code to your trans (these are sample headers, the most interesting for you is the last one):
//set the headers to next step
var header_accept_charset = "utf-8";
var header_cache_control = "max-age=0";
var header_user_agent = "batman browser";
lal = "lalvalue_fooo";
lel = "lelvalue_meeeh";
var cookie = "lol="+ lol +"; lal="+ lal;
Now make sure the vars are passed to the next step, the http client (click on get variables to fill the rows of "fields"), this should works.
The cookie is just another request header, a string simply built with the concatenation of variables and values with semicolons.
PD:Maybe this method works with the Rest Client step, if works also with this step let me know, i am interested to know that.