Rest doc for PUT request with request param but without request body setting content type as form url encoded - spring-boot

I have noticed that rest doc (HttpRequestSnippet.java) is setting APPLICATION_FORM_URLENCODED_VALUE as content type for PUT with request parameter and without request body. This should be corrected, may be introducing a MEDIATYPE as NONE and set content type as NONE or ALL when request body/content empty.
For example, my put request is like below:
/api/v1/config/?mode=unknow

This sounds like a bug in Spring REST Docs' HttpRequestSnippet for which I've opened an issue.

Related

How to Get request body in spring cloud gateway

Is there a way I can extract the request body (JSON) from the spring cloud gateway?. I went through a few approaches like RequestBodyrewrite and all, but as far as I understood it is used for modifying the response body. In my case, I wanted to get the request body and do some logic there and send the data via headers to the underlying microservices. Right now I am getting the request body with the attribute "cachedRequestBodyObject" with the help of the request body predicator.
readBody(SomeClass.class, s-> true)
I don't think I am not fully making use of the request body predicator here. We would also get this as part of the getRequestBody() method but it has a data buffer as a return type, so not sure how to get the JSON details from the data buffer. Is there a way better approach to do this ?..
Thanks in Advance.

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

JMeter not attaching contents of binary file to POST data in HTTP Request

I'm attempting to simulate a login call with JMeter 2.11 to a service that uses a binary format. I've created an Http Request with the appropriate settings, except for the body data. I need to POST raw binary data.
According to the docs here, I should be able to set the file path for exactly one file, with no parameter name, and no other content in the Body Data, and have it place the data in the request body.
If it is a POST or PUT or PATCH request and there is a single file whose 'Parameter name' attribute (below) is omitted, then the file is sent as the entire body of the request, i.e. no wrappers are added. This allows arbitrary bodies to be sent. This functionality is present for POST requests after version 2.2, and also for PUT requests after version 2.3.
However, when I run the test, the POST Data is empty.
I have tried the extra set of plugins for JMeter as well, but alas, I'm stuck. The loaded file has 145 bytes of data, and the request shows that the content-length is 0. What am I missing?
The Http Request
The result
Update 1
To clarify, I am NOT attempting to send a file, I'm attempting to send a binary encoded message as raw POST data.
Switch back to Parameters tab not Post body.
See:
http://jmeter.apache.org/usermanual/component_reference.html#HTTP_Request
Yoy could try recoring to see how the resuest look like.
This is my solution,maybe not best, but it works fine:
1st step :
You should write your binary data to a file (assume it's name is
FILENAME);
2nd step :
For your http request sampler,Yout should put ${FILENAME} under file
path in the "Send Files with the request" section (while leaving its
paramter name empty and specifying an encoding (for binary, it is
application/binary)).
Hope it helps.
Refer to this article

wireload / Ratatosk : How to make POST requests?

In my Cappuccino frontend I'm using Ratatosk to make queries to a RESTful JSON-based API.
When I create a new resource with
[myNewResource ensureCreated];
my backend returns the status code 201 and a Location header with the URI of the newly created resource. The response body is empty. As far as I know, that's the way a REST API should react to successful POST requests.
But upon receiving the response, Ratatosk calls
- (void)connection:(CPURLConnection)aConnection didReceiveData:(CPString)data
(in WLRemoteLink.j) and tries to decode the response body. This throws an error because the response body is empty. As a consequence, the request is repeated infinitely.
How should I go about this? Am I supposed to return the whole resource in the response body?
EDIT:
Returning the ID in the response solved the problem, like
{"id":1}
Ratatosk expects the status code 204 (no content) if the response is to be empty. Otherwise it expects the full representation of the resource which was just created (which it uses to populate server side dynamic properties locally like created_at).

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