Wrong encoding in json response jmeter - json

via Jmeter I get the json response:
{
"status": 0,
"response": [ {
"id": "123456789",
"login": "xxxxxxxxxxxxx",
"email": "xxxxxxxxxxxxx#xxxxxxx.xxxxx",
"system": "portal",
"firstName": "ÃÂûõúÃÂõù",
"middleName": "ÃÂðÃÂøûÃÂõòøÃÂ",
"lastName": "ÃÂþÃÂõÃÂþò"
}]
}
How can I solve this problem of wrong encoding for this response? The text is russian.

Try with last nightly build (upcoming 2.10) it should be ok, if not report a bug.
2.10 should be released in few weeks from now.

Related

Amadeus flights API error: carrier code is a 2 or 3 alphanum except YY and YYY

I am using the following SDK to search for and purchase flights via Amadeus:
https://github.com/autotune/amadeus/pull/1/files
This was a previously abandoned project I have decided to take on and make work. As part of that project I am trying to purchase a ticket in the sandbox environment and getting the following error:
{
"errors": [
{
"code": 477,
"title": "INVALID FORMAT",
"detail": "carrier code is a 2 or 3 alphanum except YY and YYY",
"source": {
"pointer": "/data/flightOffers[0]/itineraries[1]/segments[0]/operating/carrierCode",
"example": "AF"
},
"status": 400
}
]
}
Here is the json data being sent:
{
"type": "flight-order",
"travelers": [
{
"id": "1",
"dateOfBirth": "1990-02-15",
"name": {
"firstName": "Foo",
"lastName": "Bar"
},
"gender": "MALE",
"contact": {
"emailAddress": "foo#bar.com",
"phones": [
{
"deviceType": "MOBILE",
"countryCallingCode": "33",
"number": "5555555555"
}
]
}
}
],
"ticketingAgreement": {
"option": "DELAY_TO_CANCEL",
"delay": "6D"
},
"remarks": {},
"operating": {
"carrierCode": "UA"
}
}
Any help appreciated!
The error suggests that the sent payload is invalid. I'd advice you use a tool like Curl or Postman to verify you're using the right API documentation, before debugging actual code.
After further reading your PR and checking the API reference at :
https://developers.amadeus.com/self-service/category/air/api-doc/flight-create-orders/api-reference
I think you need to confirm that the Carrier code being passed is available in the segments under:
flightOffers > itineraries > segments
Although the API reference doesn't have operating > carrierCode like you used in the data sent, my guess after seeing the API error response you shared is that they are performing a check against the flight offers passed.
I suggest you check the results gotten when you call the flightOffers and also add it to the payload sent to the sandbox.

How to handle assertion property content for differenrt responses?

I would like to handle assertion property content according to below responses, for both success and failure.
Success response:
{
"task": "userLogin",
"response": {
"code": 0,
"status": "success",
"error_message": "",
"success_message": "",
"data": {
"userId": "65",
"username": "indian",
"email": "test#gmail.com",
"token": "b0aef6139ffdc1041e01f7587a0dcf61",
"userType": "trial",
"profile_picture": "test.png"
}
}
}
Failure response: will have only the data node missing, and remaining nodes will be present.
"data":
{
"userId": "65",
"username": "indian",
"email": "test#gmail.com",
"token": "b0aef6139ffdc1041e01f7587a0dcf61",
"userType": "trial",
"profile_picture": "test.png"
}
You can use a very simple XPath assertion, keeping in mind that internally SoapUI converts everything into XML representation.
XPath:
exists(//*:data)
Expected:
true
Update based on your comments.
Your original requirement was not clear. The node is present it is just empty. In that case the XPath assertion would be:
empty(//*:data)
Expected:
false
Handy XPath reference.

FIWARE: token_script error parsing json response

I am trying to generate an access code using the script
https://raw.githubusercontent.com/fgalan/oauth2-example-orion-client/master/token_script.sh
I believe the response json has changed and the sed pattern is not working anymore.
How can I generate a valid access token?
Json response:
{
"access": {
"token": {
"issued_at": "2015-05-12T14:29:03.523315",
"expires": "2015-05-12T15:29:03Z",
"id": "?????",
"audit_ids": [
"????"
]
},
"serviceCatalog": [],
"user": {
"username": "pedro#viur.pt",
"roles_links": [],
"id": "pedro-almeida",
"roles": [],
"name": "pedro#viur.pt"
},
"metadata": {
"is_admin": 0,
"roles": []
}
}
}
line that generates the token
TOKEN=`echo $RESP | sed "s/{\"access\":{\"token\":{.*\"id\":\"\(.*\)\"},\"user.*$/\1/g"`
I have tried to use the access:token:id returned but it does not work.
The new id is also shorter then the old ones
Thanks
This problem was caused by the IdM migration at FIWARE Lab in early May 2015. After be aware of it, the PEP at orion.lag.fiware.org and token generation script have been fixed.
Please, donwload again the token_script.sh file and try again. It should work.

parsing JSON object to get filelocation

i am new to JSON. Here i am facing problem how to get file location from JSON object, i am using javascript to parse the json
{
"_embedded": {
"binaries": [
{
"fileLocation": "http://images.clipartpanda.com/sports-equipment-clipart-black-and-white-soccer-ball-hi.png",
"username": "testuser3",
"description": "The company required the 28-year-old's help on a matter the directors felt could affect the share price: its Wikipedia page. Short, uninteresting .",
"createdAt": "2015-02-01T21:47:07.000+0000",
"updatedAt": "2015-02-01T22:42:16.000+0000"
},
{
"fileLocation": "http://images.clipartpanda.com/sports-equipment-clipart-black-and-white-soccer-ball-hi.png",
"username": "Sumanth",
"description": "Sample",
"createdAt": "2015-02-23T21:37:13.000+0000",
"updatedAt": "2015-02-23T21:43:11.000+0000"
},
{
"fileLocation": "http://images.clipartpanda.com/sports-equipment-clipart-black-and-white-soccer-ball-hi.png",
"username": "as",
"description": "as",
"createdAt": "2015-02-02T22:46:00.000+0000",
"updatedAt": "2015-02-27T22:06:18.000+0000"
}
]
}
}
i want to read all file locations from JSON object .
Can anyone help me. Thanks in advance
The way you are trying to access fileLocation looks right:
data._embedded.binaries[1].fileLocation
Before that, to parse your data use:
parsed = JSON.parse(data);
Here's a fiddle: http://jsfiddle.net/01aL5upc/
Note that I did remove whitespace and the apostrophe in 28-year-old's in the fiddle, to put it in to a string rather than an ajax request.

How does one enforce HTTP responses as JSON messages?

I am quite new to json and webservices.
I have a question which might as well be a dumb one but I have not been able to find an answer.
Lets say I have a html form which performs a GET method on submission.
The server performs an HTTP response.
How does one make sure that the content(body) of the response is in JSON format?
-V
This is quite a vague question as I don't know what your server is doing and replying (obviously it should be in the JSON format response) but you should also include a Content-type HTTP header as shown below so the browser knows it is receiving JSON:
Content-type: application/json
Your JSON response should look like this (taken from Wikipedia):
{
"firstName": "John",
"lastName": "Smith",
"age": 25,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": 10021
},
"phoneNumbers": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "fax",
"number": "646 555-4567"
}
]
}
data=response_from_the_page;
try {
json = $.parseJSON(data);
} catch (e) {
// not json
}