Below is my scenario
1.login - from the response of login I will get one id
2.save answer - a user has to give 16 answers for that I am using loop controller + id which I am getting from login sampler
3. Submit - I need to submit the call if I am getting success on all 16 answers + I have to use response login id
What is the best way to do it in JMeter please suggest
Given you have rest in your tags I believe the server responds with a JSON so you can save the id from the server into a JMeter Variable using JSON Extractor which allows executing arbitrary JsonPath queries to get "interesting" attributes values from JSON.
With regards to sending the requests, most probably you will need to send Content-Type header with the value of application/json, it can be done via HTTP Header Manager
Related
I am passing json data to a post request via a web task.
The body contains a number of records that are to be saved by the api.
The body returned contains a status per record sent, but within the webtask i cannot see the over all status of the post request.
In postman, the overall status shows up like below:
This status and response code (429 in this case) is not visible in the output of the webtask.
Is anyone aware if i can view this in the webtask, as its clearly visible via postman.
Thanks,
I don't believe there's any way to get this; some time ago the MS response was to create a fn app to capture it and call that from adf :)
However you can at least distinguish 2xx from 4xx by using the On Success and On Failure dependencies in the pipeline
Situation:
Using recording with Jmeter I have generated a list of api requests. The way my test object works is that when you login using UI it creates a key for the entire session (which also keeps on changing), however there is an option of having a static api key for a user that you can use for all requests when sending the api requests NOT using the UI of my software.
Problem:
I have a list of api requests that I want to test but I would like to overwrite only one variable in the header of all my api requests (i.e. adding the static api key).
Is there a way of overwriting only one variable in all (most of) the headers?
The Header Manager lets you add or override HTTP request headers.
Create a header manager at the top and enter the common value. This value will be send with all the headers.
For more information check the below link:-
https://www.blazemeter.com/blog/using-jmeters-http-header-manager
Hope this helps.
Add/Copy desired HTTP Header Manager above the Thread Group OR above Recording Controller and remove/disable all HTTP Header Manager inside request samplers, all request samplers will use the Main HTTP Header by default.
Cheers!
My org is trying to use JMeter as part of a test automation suite to test some back end REST APIs. Currently one of them supports using JSON queries as a way to get filtered results back from a GET request.
We are using the JMeter UI to create these tests and since all the other API calls work under the HttpClient3.1 HTTP Request implementation that is the implementation that I am currently using to get this to work. With this implementation I get the following when looking at the failure in the results tree (response data portion) I have made the error slightly more generic to protect some IP:
java.lang.IllegalArgumentException: Invalid uri 'https://server:port/restservice/v1/users?firstname_query={"in":["User1FirstName","User2FirstName"]}': Invalid query
at org.apache.commons.httpclient.HttpMethodBase.(HttpMethodBase.java:222)
at org.apache.commons.httpclient.methods.GetMethod.(GetMethod.java:89)
at org.apache.jmeter.protocol.http.sampler.HTTPHC3Impl.sample(HTTPHC3Impl.java:229)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1146)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1135)
at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:434)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:261)
at java.lang.Thread.run(Unknown Source)
I have also tried the same request using the Java implementation and get a similar result.
If anyone has any ideas or if you need more information let me know and thank you again in advance for any help you may be able to provide.
Your HTTP Request configuration is a little bit incorrect. JSON entities contain braces {} which are not allowed in URLs so you need to encode them.
Configure your HTTP Request sampler like:
Make sure "Encode" box is ticked.
And this way you will be able to send JSON with HTTP GET Requests. You can use View Results Tree listener to inspect request and response details:
You might also need to add HTTP Header Manager to your Test Plan and configure it to send Content-Type header with the value of application/json. See Testing SOAP/REST Web Services Using JMeter article for more details on properly configuring JMeter for testing REST APIs.
I am using PostMan as a REST client to test this API method Cisco ACL Analysis API. specifically POST /acl/trace or getAClTracksStd (first go to Policy Analysis)
Here is my PostMan HTTP test call
Does anyone who is familiar with PostMan understand why I am getting this "Request method 'GET' is not supported" error from the server? I am making a POST HTTP request, not GET.(Selected from Drop down menu) It make more sense for me to get a input invalid parameter error or something.
Just to show that the endpoint url works, heres a HTTP test request that works
(same link, host->host API -> GET /host/{startIndex}/{recordsToReturn}
There's two issues that I'm seeing with your REST call. First, the error you're seeing is because the call needs to be preceded by "https://". Second, remove the interface IDs parameter and values. You should get a response with data after making these changes.
Your json looks erronuous (comma after the destIp) - and the server probably always responds with a default confusing error message in this case. (Postman is very well tested and it sends POST).
I made a Dynamic web project using Eclipse IDE. I made a simple web app for learning.
I also made a REST service (jersey implementation) which i am using for insert,update,delete and for listing records from mysql database.
Now i want that i've a registration form which has some fields. I want that before inserting the data into database using my REST service, the service should validate form data.
I searched a lot google. I understand how to validate data in my service. But i am not getting that how to show the error message to individual form field to client.
Is there any complete example of this which does not use maven and show me the whole working from submitting form to show the error messages.
Thanks in advance..please help me guys..
You should change your approach slightly to solve this problem and implement it in the following way:
First of all You should add validation mechanisms on the client side and send registration request only when this validation will be successful.
You will find form validation tutorial for AngularJS here:
https://docs.angularjs.org/guide/forms
http://www.ng-newsletter.com/posts/validations.html
and for jQuery here:
http://runnable.com/UZJ24Io3XEw2AABU/how-to-validate-forms-in-jquery-for-validation
Server should respond with propper HTTP statuses (with optional message). For example:
200 OK (or 201 Created) - when registration finished successfully;
400 Bad Request - when registration cannot be finished successfully;
So in Your actual use case:
User fills HTML form inputs;
Inserted data are validated on the client side;
When data are invalid, error message is shown in the propper place (individual form field);
When data are correct request is sent to the serwer;
Server application tries to insert supplied data to database;
If operation is finished properly, server will answer with 200 (or 201) status code. Registration is finished.
If operation is not finished properly, server will answer with 400. Client (AngularJS, jQuery, JS) will show error message.
Hopefully, my answer will help You. Ask if You need more explanation.