As i am new to webservice in jmeter ,I am not understand how to move ahead in this, I have a json response like below,How can i put assertion for the below...
{
"flightDetails": [
{
"outBoundFlights": [
{
"flightInfo": {
"departureCity": "Bengaluru, , IN - Kempegowda International Airport",
"departureDateAndTime": "2017-04-24T17:00:00",
"arrivalCity": "Newark, NJ, US - Newark Liberty Intl Arpt",
"arrivalDateAndTime": "2017-04-25T07:55:00",
"numberOfStops": 1,
"individualPricing": [
{
"passengerType": 1,
"totalTaxFeePerPaxType": 626.55,
"totalTaxAmountPerPaxType": 461.55,
"baseFareAmountPerPaxType": 165.0,
"taxandFee": {
"markup": 6.6,
"merchantFee": 40.99,
"supplierTax": 410.96
Just add response assertion in your HTTP request and add all JSON responce in Pattern to test field
You can use JSON Path Assertion available via JMeter Plugins project like:
Given you need to check whether departureCity equals "Bengaluru, , IN - Kempegowda International Airport
Add JSON Path Assertion as a child of the request returning your JSON response
Configure it as follows:
If everything is fine the result will be successful
If expected value won't match the actual the sampler will be marked as failed:
JSON Path Assertion can be installed using JMeter Plugins Manager
Related
What's the right content schema/format or protocol to use to upload a small text file to OneDrive? I'm authenticating correctly, etc., but the docs don't seem to work...
__
I'm following the documentation, exactly - and for sanity check - using Postman.
Specifically, this example from the docs:
PUT /me/drive/root:/FolderA/FileB.txt:/content
Content-Type: text/plain
The contents of the file goes here.
Error: "Entity only allows writes with a JSON Content-Type header.",
--
So I tried putting the body in a json and changing the content-type to json. I'm actually not sure what the right json schema is...
Error: "Property file in payload has a value that does not match schema."
--
I tried fiddling a bit with PUT /me/drive/root:/FolderA/tester.txt:/content
{
"name": "tester.txt",
"file": { }
}
But got Error: The name in the provided oneDrive.item does not match the name in the URL
It turned out that the : needs to be at the end of the file path...
Previously, I had tried using /me/drive/root:/FolderA:/FileB.txt:/content instead of /me/drive/root:/FolderA/FileB.txt:/content
I get the following error response:
{
"error": {
"name": "mockRequestNotFoundError",
"header": "No matching requests",
"message": "Double check your method and the request path and try again."
}
}
When I pass - as an URI param for a Postman request created via a mocking server unlike when I pass the same URI param value in a request not created via a mocking server it's working well!
URL: http://{{host}}/order/{{subUserId}}/{{BusinessDate}}/5
host: {mocking-server-url-without-http-keyword}
subUserId: 1
BusinessDate: 2020-01-12-17-07-21
HTTP request header: x-api-key : {{postman_secret_API_key}}
The main request by using the mocking server as a host which returns data correctly:
The mocked request by using the mocking server as a host which returns an error:
The mock example would need to match the path of the main request for it to be returned.
For example:
If it doesn't, it wouldn't be able to find the mock example that you're using:
I'm unsure of your particular context but you could also use different Request Headers on your main request to point to specific mock examples:
x-mock-response-code:200
x-mock-response-name:<name of the mock example>
I'm using devise on ruby on rails for authentication. Taking it one step at a time, I have disabled the cookie authentication in order to test retrieving results prior to authentication.
If I go to my browser and navigate to the url that Alamofire is visiting, I get results in JSON format like this :
{"id":250,"name":null,"username":"walker","bio":null,"gender":null,"birth_date":null,"profile_image_url":null}
I'm requesting the alamofire request like this:
Alamofire.request(requestPath, method: .get, parameters: [:], encoding: JSONEncoding.default, headers: [:]).responseJSON { (response) in
if (response.result.isFailure) {
completion(false, "")
} else {
if let result = response.result.value {
completion(true, result)
}
}
}
This is all inside of another method which simply provides with a completion handler as you can see inside of the completion handler of the Alamofire request.
I get an error every single time.
The error says:
responseSerializationFailed : ResponseSerializationFailureReason
What am i doing wrong?
This error indicates that your response is not a JSON formatted data(or something wrong with your API Response), try to use something like post man to check your API response and to make sure every thing is ok before requesting with to swift
I am using the Rest full web-service in one of my project .
As per my business module I should not give complete object module in the json response. To achieve that I am using flex JSON serializer. Wit flex json I am able to serialize the object and give only selected attribute the response.
The Problem here is when I am testing my services using JMETER tool some time I am getting partial Response in the REST full web-service.
EX: My Object Module is as below
EMployee:
name
age
address
salary
without Jmeter the response is
[ {
"name":"martin",
"age":30,
"address":"america",
"salary":2323
} ,
{
"name":"dddd",
"age":30,
"address":"gggg",
"salary":2323
}
]
When I run same service with Jmeter with 50 user in 10 sec 1000 loop I am getting following response
[ {
"name":"martin",
"age":30
} ,
{
"name":"dddd",
"age":30,
"address":"gggg",
"salary":2323
}
]
you can see in the above respons. The first employee details coming only name and age. address and salary is ignored.
Please anyone help me in that to resolve this problem
Thanks,
Lokesh Sajjan
I am currently developing a web app which should do restful service calls to existing web service api.
What I have is the base URL and the API names.
Any help on how do I start working on it?
I suppose I need to use httpbuilder for the base url I have, then followed by /api name. But how do I test it on grails if its working?
When I paste the base url on the browser it does return some xml information, so what I need is to do it on grails instead.
XML response when I paste the url through browser
<ns1:createNewUserResponse>
<userId>21</userId>
</ns1:createNewUserResponse>
So I need to be able to get this response through my web-app (grails) instead of pasting it on the browser.
EDIT*
this is a good example I found useful
#Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.0-RC2' )
import groovyx.net.http.*
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*
def http = new HTTPBuilder( 'http://ajax.googleapis.com' )
// perform a GET request, expecting JSON response data
http.request( GET, JSON ) {
uri.path = '/ajax/services/search/web'
uri.query = [ v:'1.0', q: 'Calvin and Hobbes' ]
headers.'User-Agent' = 'Mozilla/5.0 Ubuntu/8.10 Firefox/3.0.4'
// response handler for a success response code:
response.success = { resp, json ->
println resp.statusLine
// parse the JSON response object:
json.responseData.results.each {
println " ${it.titleNoFormatting} : ${it.visibleUrl}"
}
}
// handler for any failure status code:
response.failure = { resp ->
println "Unexpected error: ${resp.statusLine.statusCode} : ${resp.statusLine.reasonPhrase}"
}
}
but i do not understand the query part and how do I alter it to my need?
the URL I have contains credential of username and password, the response should return a securityToken which I need to get it out from the results. Any help would be greatly appreciated!
You can start with groovy-wslite, it provides both SOAP and REST webservice clients.
To make a call to a resfull service look at Groovy HttpBuidler - http://groovy.codehaus.org/HTTP+Builder