how to split json response as MultipartForm data with a given boundary value in Spring REST - multipartform-data

My Spring REST service responds with a huge json Response,
i wanted to split that json with Multipart/form-data with some boundary value how could i do that,
this is what i tried
headers.add("Content-Type", "multipart/form-data;
boundary='SOMEBOUNDRY_VALUE'");
But i don't know how to split the response object values, can i just put the phrase "SOMEBOUNDAY_VALUE" ? between the large attribute values of response object ?
any help would be a great help, i'm using Spring Rest
Here is the Response i get from SOAP
Response Header from SOAP
response is not full and truncated though

I solved this by manually adding delimiter after every json value of each attribute, if the attribute is more then 2mb in size then i split the attribute to 2MB and separated by adding delimiter to it,
the reason why we needed multipart/form-data in our service response is our security layer won't accept more then 2MB attribute value while processing it, so we split the large attribute in to arrayList and added delimiter at end of each array value, which can be re-phrased at client side which served the purpose
headers.add("Content-Type", "multipart/form-data;
boundary='SOMEBOUNDRY_VALUE'");
still be there to indicate the response type is mulltipart/form-data along with the above specified delimiter logic

Related

How to accept multiple attachment along with other string data in spring boot rest endpoint(post) using #ModelAttribute?

I have a RestController which is supposed to accept json data from front end. The data contains userId and mutilple files. From front end(reactjs) I am sending as shown in the image below but not able to receive at the controller.
My controller method is here:
Here is my EnrolmentDto class:
Anyone help me please.

Is attribute [Produces("application/json")] enough to prevent all xss attacks in WebApi&ReactJS app?

I'm developing SPA using ASP.NET Core and ReactJS.
In some places of application users have an opportunity to create comments, that will be shown everyone. So I have string inputs in controllers, and I save data 'as is' in database.
I've added attribute [Produces("application/json")] for each controller - to return json as results (I don't use server-side render).
My question: should I additionally encode input data (before saving in DB or before sending to user) - or this attribute automatically encodes all strings (before sending to user) and I won't have any chance have XSS attack in my application?
Thanks.
As the docs specify
A filter that specifies the expected Type the action will return and
the supported response content types. The ContentTypes value is used
to set ContentTypes
The Produces attribute will only define what the action/method will produce, it will not encode any input string

How to keep an Array in Jmeter parameters request field

i need to add this array in the parameters in Jmeter inorder to complete the POST request. And i am getting a 400 error.
This is the array, which needs to have a POST request:
conditions :[{accountStatus: 'UNVERIFIED'}, {accountStatus: 'INVITED'}]
Just add a Parameter with blank name and put your JSON array as a value like:
You can use View Results Tree listener to inspect request and response details:
Also make sure you add HTTP Header Manager to send at least Content-Type header with the value of application/json
Add the JSON data in Body Data tab instead of parameters tab.
Another solution:
Add to the list of variables
Name - "someArray[0]"
Variable - "someText"
See more about Request options here

Thread get - just metadata

I am doing full sync this way: list of /threads and then a request to get each of the thread like /threads/{id}. However this returns me every message together with it's body data -> and I just want to fetch the metadata of the messages. I can see that in get 'messages/{id}' you can specify format but not in get threads/{id}
Threads.get() now supports format=METADATA and with that you can use the new "metadataIncludeHeaders" to further limit the headers list to a select few. This is much more efficient than using "fields" as it only fetches what is necessary from the backend rather than filtering it later on:
https://developers.google.com/gmail/api/v1/reference/users/threads/get
I assume that by metadata you mean the headers (no body). You can use the fields parameter to get just that (messages/payload/headers):
https://www.googleapis.com/gmail/v1/users/me/threads/{thread-id}?fields=messages%2Fpayload%2Fheaders&key={YOUR_API_KEY}

extjs store not loaded bu server returns json response

My extjs store is not loaded even if the server reutrns a correct json response.
I checked that the fields return from the response has the same names as the fields defined in the store.
The grid is just blank.
What can I check?
You should check you are returning an array of objects to ExtJS. If you are returning an object, containing the array of objects as a field, make sure you specify rootProperty for JsonReader to find the array. Make sure you are using correct data reader (i.e. JsonReader).
You may also try adding data from response manually into store via add to check that the data fits in well.

Resources