Hi I'm new to jmeter with bean shell script.
I want test my web service such that service only accept zipped json content.
(Accept: application/json
Content-Encoding: gzip
Accept-Encoding: gzip, deflate)
I have following queries:
How can I encode json request parameter as gzip using bean shell script?
Can we use any custom java class to encode (using bean shell's calling external java classes property) and bind with request ?
I simply want to do json ->Gzip -> request parameter in jmeter
Regarding #2, so long as your JAR is in a known class path you should be able to use it with beanshell...however as I am sure you have seen, JMeter does not provide much feedback when it comes to debugging beanshell.
Related
IntelliJ has an HTTP client. When composing a file that is interpreted by the HTTP client, you can specify headers that go out to the server with the request, like so:
###
GET https://{{hostname}}/{{path}}
Content-Type: application/json
X-Auth-Token: {{x-token}}
I want to find the actual value of the token that was used to replace the variable name, seen above as {{x-token}}, but I don't see any way to obtain the request headers. The response headers are obviously available, but not the request headers. See the image below for the test results that are shown after running the HTTP client inside Intellij:
Is there a way to display the REQUEST headers?
Link to IntelliJ Documentation - HTTP Client -- the documentation seems to never mention the actual request headers that are sent over the wire, but they do discuss how to define request headers in composing the .http file type.
Check the Tools | HTTP Client | 'Show HHTP Requests History' action.
I've created an ASP.NET Core web application, and installed + used the Swashbuckle.AspNetCore version 6.1.5 Nuget package. This hosts the following openapi document on https://example.com/swagger/v1/swagger.json.
Also my API supports content-negotiation.
When sending no Accept header, or Accept: text/xml header, the api will return an XML string
When sending an Accept: application/json header, the api will return a JSON string
Now I've tried consuming my api through the swagger document:
Create a new .NET Core console application
Right-click the project file → Add → Service Reference
OpenAPI
URL: https://example.com/swagger/v1/swagger.json
Namespace: Example.Api
Class name: ExampleClient
You can then write a Main like this:
static async Task Main(string[] args)
{
Console.WriteLine("Hello World!");
var httpClient = new System.Net.Http.HttpClient();
// httpClient.DefaultRequestHeaders.Add("Accept", "application/json");
var mintPlayerClient = new MintPlayer.Api.MintPlayerClient("https://mintplayer.com", httpClient);
var artists = await mintPlayerClient.ApiArtistListAsync(false);
}
Now when you debug the console app
navigate to the ApiArtistListAsync method in the swaggerClient class
put a breakpoint at the client_.SendAsync call
you can now inspect what the swaggerClient is sending to the webservice
Usually it's like this:
SOAP = XML
REST = JSON
Even when adding a DefaultRequestHeader on the HttpClient the response from the HttpClient is an XML, because it's explicitly added inside the SwaggerClient method:
And here is how the code is generated + the line where the Accept header is explicitly set (swaggerClient:430). This is auto-generated code from adding the service-reference.
So why is the Accept header in the generated code explicitly set to text/plain? Why isn't the default accept header value application/json, since this is a REST service?
I think you might want to check this on both side, client(your console) and server(your api project).
We all know that usually
SOAP = XML
REST = JSON
But you're coding the whole things, total in-control of what being send and what being response.
Let's assume you client send Accept-Header which support both text/xml and text/plain (which as i understand here, you expect a response as text/plain).
Then the server realize that your console is happy with either text/xml and text/plain, and the server itself support all kind of common format.
So it'll have to electing the most convenient format to response to the client.
Which in this case is text/xml.
That's so, the console received and happy with text/xml response format either way
And if that's the case, that I get you right, you want to receive text/plain on the console, then make sure the only Accept header sending out is text/plain or do some custom logic on your API to choose the text/plain format over others when sending response.
I want to send <MYURL>/myaddres?path=<MYPATH>&content=<MYCONTENT> to a service with editor based REST client in IntelliJ, but take the content of <MYCONTENT> from a file.
Is it possible?
Yes, you should type the < symbol followed by the path to the file:POST
POST http://example.com:8080/api/html/post
Content-Type: application/json
< ./input.json
More info: https://www.jetbrains.com/help/idea/exploring-http-syntax.html#provide-request-body
I want to make an API call using Jmeter.
In my API call, I'm sending a file with a request,
and I need to specify the file name as form-data.
e.g. when I call the same API from postman !
How do I, specify a filename when I make above call from Jmeter?
Jmeter call :
HTTP Request Sampler provides options to
set Use multipart/form-data for HTTP POST
send files with the request
See Performance testing: Upload and Download Scenarios with Apache JMeter guide for detailed explanations and configuration instructions.
I am trying a Performance scenario where single user logs in to web application.
For that i am using Jmeter and REST-APIs
Here i have to call REST-APIs for that i have used "HTTP Request Defaults", I have created one thread group and added one "HTTP Request Default".
From APIs i have to pass two parameters:
1) User Name
2) Password
What would be the syntax of parameters in HTTP Request Defaults? or what sampler i should use for this?
I have one API link from which we can trigger those parameter, which will get applied on web application.
First of all you'll need a HTTP Header Manager configured to send the following header:
Name: Content-Type
Value: application/json
Elsewise your request may not be processed as needed
The sampler you need to use is generic HTTP Request sampler. The easiest way to provide JSON payload is to switch to Body Data tab and put your JSON there as below:
Optionally you may with to use JSON Path Extractor for correlation
See Testing SOAP/REST Web Services Using JMeter guide for a quick ramp-up on the RESTful web services testing domain.
for ease of use
In your Jmeter click on File, select Templates
In the opened window/dialog, select "Building a SOAP web-service test plan"
Click on Create.
It will open a test plan, which should give you a fare idea on how to achieve your scenario.
Hope this will help.