How to retrieve body form-data in key value pair and use it in postman test script - testing

request body form-data
I tried the following but didnot work
pm.request.body.data
pm.request.data

Access this format
pm.request.body.formdata.get("name")
pm.request.body.formdata.get("last_name")
pm.request.body.formdata.get("other_name")
Documentation in here
formdata :PropertyList.<FormParam>
Form data parameters for this request are held in this field.
Type:
PropertyList.<FormParam>
Usage in Tests tab.

Related

Variable Path Param for GET request in Jmeter

I'm testing a GET request using Jmeter, this request has path parameter:
rest/V1/autobusca/marketplace/product/:productSku
I'm trying to send the parameter in two different locations
Send Parameters With the Request
And I insert a "User Parameters" as productSku and the value.
I noticed the code response is 200, but the body response is "[]", but when I send it using Postman the response body has a lot of information.
If I change the path in the request like this:
rest/V1/autobusca/marketplace/product/${productSku}
I noticed the code response is 404. Can you help me?
Use "//" instead of "/".
Correct URL will be : rest/V1/autobusca/marketplace/product//${productSku}

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!

Unable to upload multipart file in karate, Required request part '' not present

ActualAPIRequest OutputFromKarate
Trying to upload a json file for an api using karate. Since api takes multipart input i am passing multipart configurations in karate.
But Required request part 'inputData' not present error is coming. Is there any solution for this please?
I have attached actual input and result from karate screenshot for reference
Just make sure that the data type of inputData and maybe swaggerFile is JSON. Looks like you are sending a string.
Please refer to this section of the doc: https://github.com/intuit/karate#type-conversion
If the server does not like the charset being sent for each multipart, try * configure charset = null

ShopStyle API - How to Invoke an HTTP request

How do I Invoke an HTTP request with a particular URL and process the body of the response as XML?
Information Provided by ShopStyle:
HOW TO USE THE API:
Choose the method that returns the data your application needs. For example, the /products method is used to get products that match a given category or brand.Construct a URL for that method with the appropriate host, method name, and query parameters. Invoke the URL as an HTTP GET.
When the HTTP response arrives, extract the required data elements from the response's body.The rest of this document describes the details of constructing the right URL for each of the API methods. The XML format of the responses may be seen by clicking on the sample URLs shown for each method. The responses in JSON format contain identical information, just in a different format.
SHOPSTYLE API URLS
All ShopStyle API URLs have the following form:
http://api.shopstyle.com/api/VERSION/METHOD_NAMEpid=YOUR_API_KEY&format=FORMAT&...
The METHOD_NAME is taken from the list of methods in the various API shown at left (Press Link To View List of Methods-https://www.shopstylecollective.com/api/overview).
COMMON API PARAMETERS
All methods in the API accept these parameters:
API_KEY (my unique key is ******************)
pid Unique API_KEY string that is assigned to the caller. You can find your API Key on the Account Settings page.
FORMAT
The format of the response. Supported values are:
json - The response is in JSON format with UTF-8 encoding. This is the default if the parameter is absent.
xml - The response is in XML format with UTF-8 encoding.
jsonp - The response is in JSON format with UTF-8 encoding wrapped in a JavaScript method called padding. The padding must be specified with the query parameter 'callback'. Only single expressions (function reference, or object property function reference) are accepted as valid padding.
When set to 1 or 'true' the HTTP status will always be 200. Use the field "errorCode" in the response to detect whether the API Call was successful. By default, when an error occur the HTTP Status of the response will be different than 200
Again I am a beginner, so please provide detailed information on how to retrieve CATEGORY data (Examples: Dresses, Tops, Buttoms, etc) in XML format.**
Thank you!!!
Here's a simple example to get your started. Copy the code below and put it into a file, say "cat.php". Then run it by typing "php cat.php" at a command prompt (assumes you have php on your machine):
<?php
// don't show dom parse errors
libxml_use_internal_errors(true);
// grab the xml from the api
$response = file_get_contents("http://api.shopstyle.com/api/v2/categories?pid=TEST&format=xml");
$doc = new DOMDocument();
$doc->loadHTML($response);
// grab all the categories
$elements = $doc->getElementsByTagName('categories');
foreach($elements as $node){
foreach($node->childNodes as $child) {
// get the name out of the category
$nodes = $child->getElementsByTagName("name");
foreach ($nodes as $name) {
echo $name->nodeValue . PHP_EOL;
}
}
}

How to pass regular expression extracted value in json format for PUT call in jmeter?

I am testing RESTapi with (json format) using (HTTP Request sampler) in jmeter. I am facing problems with the PUT calls for update operation.
The PUT call with parameters don't work at all using (HTTP Request sampler), so now i am using the post body to pass the Json.
How can i pass the extracted values from the previous response to next PUT request in thread group? Passing the 'Regex veritable' to PUT call in Post body don't work, it doesn't take ${value} in Post body.
How do i carry out UPDATE operations using (HTTP Request sampler) in Jmeter?
Check that your regexp extractor really worked using a debug sampler to show extracted value.
Check your regexp extractor is scoped correctly.
See this configuration:
A Variable:
Its use with a PUT request:
The sampler result: