I have the following situation:
I have a POST request having Content encoding defined as utf-8
It is posting some JSON data, however I did not correlated any of them in previous responses. The JSON data looks like the following:
["Diagnosis","Gender","MaritalStatus","PCC","CONNECTION_SOURCE_STATUS","CONNECTION_TARGET_STATUS","BED_TYPE","SECURITY_QUESTION","ADMIT_TYPE","DECLINE_REASON","HH_DECLINE_REASON","SMS_VENDOR_DOMAIN"]
The request gets failed and no exact reason is located, but I see it has returned the Response code: 403 which is Forbidden.
I'm stuck at this point. How could I resolve this issue, please advise.
The issue has been resolved. The Response Code 403 (Forbidden) was appearing because of X-CSRF-TOKEN parameter was being passed in Request Header.
I extracted the X-CSRF-TOKEN through Regular Expression Extractor Post-Processor and passed it on the subsequent requests.
Thanks
Related
I am trying to create a test plan using jmeter.its for an API Post request, I have a header manager, bodydata, checked for spellings and the syntax seems to be correct. However, Im getting 400 response code with the following error shown in the attached image. Anyone with an idea how I can resolve this? Thank you. the error
Here is the request the request
The user doesn't have to be logged in, i have added a header manager, I have also noticed there header has a cookie value thats hard coded but it appears to be the same in every request. In the UI the API request returns 200 and thats what im expecting with the Jmeter script.
In its current form the question cannot be answered comprehensively.
HTTP Status Code 400 means that
The 400 (Bad Request) status code indicates that the server cannot or
will not process the request due to something that is perceived to be
a client error (e.g., malformed request syntax, invalid request
message framing, or deceptive request routing).
Check that your ${site} and ${csVersion} variables have their respective values using Debug Sampler and View Results Tree listener combination
Cross check headers sent by JMeter and by the "UI", the most important is Content-Type
Use a sniffer tool like Wireshark of Fiddler and capture the requests which are being sent by JMeter and the "UI", the requests must be exactly the same apart from dynamic parameters which need to be correlated
The issues was being caused by an anti-forgery cookie which was hard coded in the request.I used a regex to extract the value from a previous request and used a variable value from the regex to make sure the same value is being passed on to the request that was failing.
I've tried to scrape and parse JSON data. While the below URL returns JSON data on browser, below code will generate an error by Google saying "Exception: Request failed for https://rate.tmall.com/list_detail_rate.htm returned code 302".
Also, response is valued at undefined and I could not track anything from the response.
How can I solve the issue? Thanks a lot.
var response = UrlFetchApp.fetch("https://rate.tmall.com/list_detail_rate.htm");
I think I got it. I need to bring the cookies in the header. :)
I am writing a http handler for a server and I am looking directly at the http requests when they come in from different clients. I can easily deal with normal http requests. The problem occurs when I get a GET or POST request. I do not know how to access the data from the GET or the POST therefore I cannot continue. Could someone please point me in the direction of some where which deals with the issue on how to access the data. Thanks in advance.
Answer:
to do this:
In a GET request the data comes in the URL itself therefore just parse the URL from the HTTP request and look for the question mark and the arguments.
For a POST request there are 2 different ways however the main one means that the arguments are put in the body of the request like this:
q=hello&v=world
The length is specified in the request as well so if you need it is under Content-Length:
I'm using postman to test calling a rest service endpoint.
I'm trying to parse the JSON return content but it throws an error because the response body has more than just JSON.
This is how I parse it in my postman test script:
var jsonData = JSON.parse(responseBody);
Here is the response body:
--13398550-b6ea-4731-a8ee-4b2ad24c3cfe
Content-Type: application/json; charset=utf-8
//this is the actual content I want to parse --->
{"id":"123456","value":"the_value"}
--13398550-b6ea-4731-a8ee-4b2ad24c3cfe--
When I try to parse it, I get the following error (in postman)
There was an error in evaluating the test script: SyntaxError:
Unexpected number in JSON at position 3
Obviously because the content being parsed is not just JSON
Is this something special that the api is doing? Or am I just parsing it incorrectly?
NOTE: I'm not including details of the rest service function. If the cause of this issue is something that is being done by the service itself, then that is enough of an answer for me to perhaps ask another question or do some further investigation. The purpose of this question is to ask whether this is something special being done in HTTP, or if it's the service.
Edit:
I managed to see the server side code and it is indeed manually building the response with boundaries identified by a GUID. I'll have to manually parse the response
The server is not emitting straight up application/json, it's packed in a multipart mime envelope.
Whether or not it's doing that correctly depends on the response headers. If you didn't expect a multipart response, but a simple JSON response, then I'd say yes: it's something you need to fix server-side.
I was wondering if someone could tell me why I can't see the json response from a request that is also of type json in the JMeter View Results Tree. I know that the response is there because I use a regular expression to extract data (I wrote the reg ex based on result returned in Firebug). So the data can be extracted from the json response it just doesn't display in View Result Tree. I can see the json response for another request for a different app I performance test with JMeter, but that particular request is an ajax request. not sure
Add a sample writer and display content here.
http://jmeter.apache.org/usermanual/component_reference.html#Simple_Data_Writer
You will see the issue
HI there any one who looks in this post for jmeter, you may be bit worried when you cant find answers in internet regarding how to log your response when you sent a request , here is the solution and simple as it is...
just add a line like below.
result.setResponseData("put any content here to be displayed as String.", "UTF-8");
and check your response will be cool as you done.