Sample JSON request for multipart form - json

I want to call a rest API and my request body is composed in a json file. I want to send the request as multipart/form. Request body containst some text fields and several files for which I decide to use multipart form. I have found alot of logical example requests on internet but no concrete example in json format.
How would a sample json request body look like?

Finally found out that there is no such JSON representation of multipart/data requests. Infect thats just not possible using the json format. So multipart data request literally looks like the attached screenshot:

Related

Map entire Webhook Response in Marketo Webhook

I have a web-hook that calls an API that returns a single plain text response. The response isn't formatted in JSON or xml because the response is a single piece of data, not a map or array. I see plenty of examples of how to extract a field from a JSON response and store it in a marketo token but no example of how to store the whole response payload. Here is a sample response from the API:
alsdfjasdhfalksdhfalksdjalksdk
Note that the response is not anything like this:
{
"field":"alsdfjasdhfalksdhfalksdjalksdk"
}
Maybe some Marketo expert has done this and could share. I'd appreciate it, thanks.
Marketo's parsing of XML and JSON is limited, to say the least--so your webhook does need to declare some sort of key-value pair so the response can be mapped. Given what you're describing, you could likely just hardcode in the surrounding JSON with the right MIME type and be fine.
Basically, Marketo can only handle the following for JSON webhook responses:
Key-value pair
Key can only be defined by placement (no XPath or similar--you'd be stuck with field[1] or similar)
Ideally no nesting, as Marketo doesn't do a great job of reading nested data--largely for the reason mentioned above

How to test rest API with large json

I am writing rest api with Flask. One of my endpoints handles a post request. One field of the request JSON 'audio' is supposed to contain the BASE64 encoded PCM file (audio format). If save this field to a file, it is about 200KB.
It might be too big to copy and paste in Swagger or Postman for testing. Even worse with curl command. Is there any good way to test with really big JSON in the request.
I'd recommend a great tool called Insomnia. You can send point it to any file to send it as a HTTP request. You can change the Content-Type header to be application/json and select your JSON data file. Here's a screenshot of what the program looks like.

How does JSON data get sent in an http request?

Let's say I'm making the http request below, to update some record in a mongoDB database:
PUT
http://dev.mycompany.co/ping
{"id":4432, "name":"Jane Doe", "products":[ {"id":287}, {"id":434} ] }
Notice that there is an array of two objects inside the "products" property of the JSON above. I have data that is being sent in this general format, both through Fiddler and through a ruby script I've written.
When sent through Fiddler, my data in the JSON is correctly parsed and updated into my database. When sent through my ruby script, the data in the JSON is not parsed correctly. I've been trying to figure out why this is. Now, I'm wondering how data is actually sent when a JSON is sent along with an http request. Can someone point me in the right direction?
After asking a few other questions on SO and doing a bunch more research, I've arrived at the following conclusions.
Q: How does JSON data get sent in an http request?
A: It depends on how you are sending the JSON data in the request (what is the content-type)
I've encountered two ways that JSON data is sent.
Sent using content-type application/json
With this content-type, JSON data is sent literally as-is. The literal JSON data is stored as a string and sent with the request. If your JSON is complex, with nested objects and arrays and such, this is probably what you want. For a working example of sending nested JSONs using Ruby's Net/HTTP, see the answer on this SO question I asked.
Sent using content-type x-www-form-urlencoded
This is how Ruby's Net/HTTP requests typically get sent out. The form of these requests is something like: id=343?entity=Microsoft?foo=bar. This content-type is fine until you have a complex JSON.

Is there any online tool that can be POST requested with json payload to be pretty printed?

There are plenty of online json viewers. Yet if there are any that may be POST requested with json payload so that incoming json string might be pretty printed? Not just copy/paste as usual?
Use https://webhook.site/. It provides a unique json receiver for you that shows your http requests.
Here's two sites you can try for your requests:
https://www.hurl.it
http://gurujsonrpc.appspot.com
Here is the link which i use to parse the json data i get from services.
All you have to do is to copy the json and paste in it, it will give you a very clear preview of the data.
json parser

Can't see JSON response in JMeter View Results Tree

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.