JMeter: Passing Key Value Pairs Not Working - api

I'm using JMeters to automate API testing to/from our database using basic CRUD methodology. After the record creation, I'm trying to perform 3 different types of Reads (think CRRRUD). :)
Read 1 - Retrieve by ID
HTTP (GET) the base URL is appended with the saved record ID.
http..../crud/tableName/${newRecordId}
This returns
Read 2 - Retrieve by field type with no defined value
HTTP (POST) the base URL is extended with a "search" as the end. A Key is defined ("name") with no value.
http..../crud/tableName/search
Parameter Name = name
Value = {undefined}
This returns all records within the table whose field ("name") is not null.
Read 3 - Retrieve by field type with a defined value
HTTP (POST) the base URL is extended with a "search" as the end. A Key is defined ("name") with the value generated during the creation request.
http..../crud/tableName/search
Parameter Name = name
Value = Metropolis
This, too, returns ALL of the records within the table instead of just the record(s) whose name = Metropolis.
This 3rd Retrieve works properly when using a REST client, (e.g., Postman, Advanced REST Client, etc.) when defining the Key|Value pair as "name|Metropolis". So it must be something within JMeter that I'm missing.
Any insight is appreciated!

There is only one correct answer: compare what's being sent by REST Client and JMeter using sniffer tool (i.e. Wireshark), detect the differences and configure JMeter accordingly.
Just a guess: given you mentioned "API" an "REST" words maybe you need to pass it as JSON like:
{"name":"Metropolis"}
as a single parameter value
or in formatted way (in case if server checks Content-Length and/or wants the request to be properly formatted)
You may also need to add HTTP Header Manager in order to send Content-Type header with the value of application/json. See Testing SOAP/REST Web Services Using JMeter guide for more details.

Related

Is it possible to call a URL in a Splunk dashboard and get the response as a string?

I have a Splunk dashboard where you have a table with selected encoded identifiers.
You can click on a row and select an identifier as a token which fills additional fields with data. Now on the intranet of my company we have a url where you can enter the encoded identifier and get back the decoded data in a GET request.
Right now I have a single-value field which displays the encoded identifier and when you click on it it makes a call to the decoder and opens the decoded result in a new tab. That's a standard Splunk link.
Is it possible to make Splunk call the URL automatically (do a GET request) when the identifier is selected (the token is set) and retrieve the response data as a string and extract (using regex) and display the decoded data automatically in the single value field?
If not, is it at least possible for Splunk to get the response data as a string instead of opening the result in a new tab when you click on the encoded identifier?
If I understand you correctly, you want to have the drilldown target be an external link.
If that is correct, just put the external URL in the drilldown:
If you want some value from an external link to be pulled-into Splunk, then you'll need to setup another mechanism.
For example, you might have a scripted input that will query an external endpoint, and add results to an index or lookup table.
Or you might utilize a REST endpoint app to achieve something similar.

I want to pass the header value in methods

Scenario : I need to verify the logs response on server on the basis of Tracking-Id.
I had passed the tracking-id using 'header.js' file, here i define metod which get the unique UUID for every request and passed in header.
Now I need that header value to passed in some method to get logs only for specific Tracking-Id
Is there any way to achieve this in karate?
Yes, you can use karate.set('someVarName', uuidValue) in JS and then back in the feature you will be able to: * print someVarName.
EDIT: please see this commit for an example: link

how to give a generic value/id in HTTP request (path) in jmeter?

[The product id changes very time when the page refreshes so can you tell me how can one give a generic id/name which automatically picks the assigned id when the page is loaded.
Example
Currently what is happening:
In Path: /EAPPFileUpload/UploadFiles?currentFolder=ARA&productID=1234
What is required
In Path /EAPPFileUpload/UploadFiles?currentFolder=ARA&productID=variable
where variable shall possess the id in it.]1
My expectation is that this "product id" doesn't come out of nowhere, most likely it exists somewhere in previous response, either in body, or in headers or in URL.
So you need to extract the value from the previous response with i.e. Regular Expression Extractor, save it into a JMeter Variable and replace hard-coded (recorded?) value of 1234 with the aforementioned JMeter Variable.
The whole process is known as correlation and has been discussed hundreds of times already.

Formulating REST API call

Here is my query string
https://api.meetup.com/2/open_events?country=us&state=ca&city=sanfrancisco&category=34&page=10&group_photo&sign=true&&sign=true
I'm having no success reaching the group_photo resource.
In the docs they say:
group_photo
Returned when fields request parameter contains "group_photo".
Represents photo for the group hosting the event
I tried changing group_photo to group_photo=true but that didn't help.
Here's the console if you wanna test it
From the Meetup API documentation:
fields: Request that additional fields (separated by commas) be
included in the output
and
group_photo: Returned when fields request parameter contains
"group_photo". Represents photo for the group hosting the event
so you must add fields=group_photo and the call you gave above would be be something like:
https://api.meetup.com/2/open_events?country=us&state=ca&city=sanfrancisco&category=34&page=10&fields=group_photo&sign=true&sign=true

Ushahidi GET request with multiple parameters

I'm working on an application that uses Ushahidi to return an array of JSON objects using a HTTP GET request. I would like to use two parameters in the request. These parameters are category id and max id. In the URL below the first parameter is &by=catid&id=2 and the second is &by=maxid&id=499. The example below will only read the last parameter entered. So the catid parameter would be ignored.
http://fixyourstreet.ie/api?task=incidents&by=catid&id=2&by=maxid&id=499
Why will this request only return JSON objects by the last parameter entered rather than both parameters?
Any help would be much appreciated.
Those requests typically get parsed as key-value dictionaries by web servers.
This means the "by" parameter can only have one value when your request is processed and responded to. You will have to make 2 subsequent requests if you need all these values :
http://fixyourstreet.ie/api?task=incidents&by=catid&id=2
http://fixyourstreet.ie/api?task=incidents&by=maxid&id=499