Conversion of json object to object in jmeter - json

I have a POST API consuming JSON Object. I need to pass the JSON as body data to the API. The conversion of JSON Object to the intended class object is failing. Do we have to specify any other parameters?

You have to specify Content-Type header to application/json using HTTP Header Manager (add it as a child to the HTTP sampler of POST request), so that JMeter sends the POST request telling the server that the body contains JSON using the header.

Related

Sim808 + Arduino UNO: Get Json Object Response from Web Server

How to read JSON object response from the server?
These are the commands I use:
AT+SAPBR=3,1,"Contype","GPRS"
AT+SAPBR=3,1,"APN","internet"
AT+SAPBR=1,1
AT+SAPBR=2,1
AT+HTTPINIT
AT+HTTPSSL=1
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","https://www.mywebsite.com/getTime?token=jsdaljdaskl"
AT+HTTPPARA="REDIR",1
AT+HTTPACTION=0
The returning request should be Json object, but the Sim808 read it as html response which gives error 606.
Need to define HTTP parameter content as JSON format using the following command
AT+HTTPPARA="CONTENT","application/json"
Found this document useful HTTP Client using SIM900.

Sending JSON response via GenericJsonWebHookReceiver MVC ASP.NET

I need to send the JSON response from GenericJsonWebHookReceiver provided by Nuget package in ASP.NET.
I am trying to send the JSON value in the return call like this - "return Task.FromResult(sampleJson);"  , where sampleJson is a valid JSON in string format.
But while testing, I am still getting empty response.
How can we send the JSON response with GenericJsonWebHookReceiver? Also how to set the proper header type in the response to define it as JSON type response?
Thanks,
/vikas

Is it a good practice to send json data in http headers

I have a REST API Endpoint endpoint/action. The method is POST having a json data in the request body. I have two headers for this
Content-Type=application/json
Custom-Header={"object":{"id":"someId"}}
The object is deserialized during processing and the "someId" is used for other processes
Was wondering if it is a good practice to send json strings/data in the http header. Couldn't find anything in the Http Header documentations.
Option would be just sending in the "someId" and fetching the object using the id

Axis2C : Sending data with Custom content type

The client (Browser) expects to receive a JSON string in response. I have the JSON string to send at the service side. However the calling function (axis2_invoke) expects axiom_node_t which make it return XML.
Is there a way to send my response in a way I want to and not as axiom objects
AxiOM is a data abstraction layer, not XML.
When talking about Axis2/C-unofficial which supports JSON natively, you will get response depending of your request format:
if you setup Content-Type of your request to application/json you will get response in JSON format;
if you setup Content-Type of your request to application/soap+xml you will get response in SOAP format.
Your response AxiOM is to be be converted to appropriate format by Axis2/C's transport sender.

How does server handle JSON in the body of a POST

I am using jQuery to post JSON data to a tomcat server and the server is handling the JSON array data perfectly! It is as though I passed key=value request parameters along with the URL.
So why am I posting this? I would like to know how the server treats JSON in the body of a request and how the data ends up being interpreted as request parameters. I have Googled my a** off and all I find is how the server sends JSON back to the client.
$.ajax() converts JSON data into key-value pairs (querystring style) by default. You need to set { processData : false } in the AJAX request to keep it as raw JSON.