Posting JSON as a request parameter not sending it raw - jmeter

I'm sending POST request on Jmeter with one of the parameters with json format. But JMeter is not sending it as a raw as you can see below. It's encoding the json and requesting with % and numbers... **msg** should be sending raw json.
I tried various options with encoding but none is working. How can I send json as a raw as a request parameter?
POST data:
trans_code=KycPartnerSender&version=1.0&pkg_id=1234123&timestamp=123123&**msg**=%7B%22sId%22%3A%7B%22weChatId%22%3A%22jnaS001%22%7D%2C%22sInfo%22%3A%7B%22firstName%22%3A%22jnaSender001%22%2C%22middleName%22%3A%22%22%2C%22lastName%22%3A%22QA%22%2C%22dob%22%3A%221958-01-31%22%2C%22email%22%3A%22001%40ZB.CA%22%2C%22taxId%22%3A%22467456789%22%2C%22mobilePhone%22%3A%224161231234%22%2C%22workPhone%22%3A%224161231234%22%2C%22citizenCountryCode%22%3A%22CA%22%2C%22residenceCountryCode%22%3A%22CA%22%7D%2C%22sAddress%22%3A%7B%22line1%22%3A%22123+Yonge+Street%22%2C%22line2%22%3A%22Suite+1902%22%2C%22city%22%3A%22Toronto%22%2C%22countryRegionCode%22%3A%22ON%22%2C%22postalCode%22%3A%22M2M2M2%22%2C%22countryCode%22%3A%22CA%22%7D%2C%22sFundingSource%22%3A%7B%22accountNumber%22%3A%22123456789%22%2C%22accountHolderName%22%3A%22JNA+SENDER%22%2C%22routingNumber%22%3A%2200402652%22%7D%2C%22rId%22%3A%7B%22weChatId%22%3A%22jnaR001%22%7D%2C%22rInfo%22%3A%7B%22firstName%22%3A%22jnaReceiver%22%2C%22middleName%22%3A%22X%22%2C%22lastName%22%3A%22QA%22%2C%22dob%22%3A%221970-10-31%22%2C%22email%22%3A%22002%40ZB.CA%22%2C%22taxId%22%3A%22789456123%22%2C%22mobilePhone%22%3A%224161231234%22%2C%22workPhone%22%3A%224161231234%22%2C%22citizenCountryCode%22%3A%22CA%22%2C%22residenceCountryCode%22%3A%22CA%22%2C%22employmentStatus%22%3A%22Full+Time%22%2C%22occupationCode%22%3A%22102%22%2C%22industryCode%22%3A%22101%22%7D%2C%22rAddress%22%3A%7B%22line1%22%3A%22123+Bloor%22%2C%22line2%22%3A%22Suite+1900%22%2C%22city%22%3A%22Toronto%22%2C%22countryRegionCode%22%3A%22ON%22%2C%22postalCode%22%3A%22M2M2M2%22%2C%22countryCode%22%3A%22CA%22%7D%2C%22rFundingSource%22%3A%7B%22accountNumber%22%3A%22987654321%22%2C%22accountHolderName%22%3A%22JNA+RECEIVER%22%2C%22routingNumber%22%3A%2200402652%22%7D%7D

Instead of using Parameters table, select the Raw Body tab and just put your json body.
Of course it only works with Post method (not Get) so it should be ok for you.

Related

How to get JSON data (body application/json) from a GET Request?

How can I get the json data from a GET request to a Django Rest route. I am making a GET request to a url and have data in the body of Postman as JSON(application/json). How do I get the data from this request in Django Rest Framework, in my view.
My view sends back data based on what is passed in the JSON data.
I do not want to put the data in the url as a query_param. I will be sending a lot of parameters in the JSON data body, so concatenating to the url is not what I want.
It is not possible to send json format with get request you have to use post request to send data else use query param with get request.
For more info see this django request and response tutorial

What is the difference between parameters and body data in HTTP request in Jmeter?

i am unable to provide request to the server in json format using parameters so please can anyone explain me about it?
I sent this request from Bodydata extracting data from CSV:
POST data:
{
"password":"login",
"username":"568592"
}
but when i used parameters for extracting data from CSV:
POST data:
password=login&username=568592
How can i send json format request using parameters?
There should be no difference given you properly pass your JSON via "Parameters" section.
If you want to use "Parameters" - just put your JSON payload into "Value" section of the 1st parameter like:
If you want to use "Body Data" - put your JSON Payload there (don't forget to remove everything from the "Parameters" section)
Don't forget to add HTTP Header Manager to send Content-Type header with the value of application/json

In JMeter Post Data Not Sent In Request When Certain Character Strings Are Included

In a test plan that I am trying to execute, there is a step that includes a post request with post data. One of the parameters in the post data includes special characters. The parameter name is '__RequestVerificationToken'. When the parameter name is spelled correctly, the request is sent with no post data included. The request fails. However when the parameter is changed slightly, post data will be included with the request. Because the correct parameter names are not sent, the request also fails. Below is a list of parameter names that do and do not break the sending of post data.
Parameter names that do break the sending of post data:
'__RequestVerificationToken'
'__RRequestVerificationToken'
'**RequestVerificationToken'
Parameter names that do not break the sending of post data:
'__TRequestVerificationToken'
'RequestVerificationToken'
Is there anything that I can do have my parameter name sent correctly without dropping post data from the request?
Did you try encoding them using 2 options:
In Http Request check the checkbox encode in the parameters table
Use function __urlencode

Do I need to send the data in $.ajax as json?

I have an $.ajax request that's sending the data in a serialize() and gets a json array in return. It works perfectly without any issues on Chrome develop's tools and Firefox's firebug. My question is, do I HAVE to send the data(user inputs) as json? I need json for the response but not for the request.
No, you send the data however you like but keep in mind how you send it will affect how you can retrieve it.
Also you aren't sending JSON in your request as .serialize() does not return JSON it returns a text string in standard URL-encoded notation.
No, you don't need to send it as JSON. You can send it in any other format, but your receiver will need to know how to interpret it. Usually people use JSON or XML since your receiver can easily parse these types of data.
You'll need to set the content-type, then you can tell the receiver how to process this content-type.

Firefox HTTP resource test post parameter

I'm using HTTP Resource Test on Firefox and want to simulate a POST request. However I didn't find where to write the post parameters. There are only URI, Representation and Headers, is there any way that I can pass with some post parameter? (In Json format?)
The payload of the post should go in the body of the request. It's shown here:
https://addons.cdn.mozilla.net/img/uploads/previews/full/54/54035.png?modified=1297743921
For example, if you were posting a JSON document you could just paste the JSON in the "Body" text area.
The payload of the post should go in 'Client Request' / 'Representation'.
It's shown on this screenshot.
As an aside, this answer describes an excellent test server to use as a sanity-check.

Resources