Skip to content

HTTP request snippet for a PUT request with a query string duplicates the string's parameters in a form URL encoded body #763

Closed
@wilkinsona

Description

@wilkinsona

Reported on Stack Overflow.

This test reproduces the problem:

@Test
public void putWithQueryString() throws Exception {
    MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
            .apply(new MockMvcRestDocumentationConfigurer(this.restDocumentation).snippets().withEncoding("UTF-8"))
            .build();
    mockMvc.perform(put("/?b=bravo&c=charlie").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
            .andDo(document("put-with-query-string"));
}

The HTTP request snippet has an unwanted body and Content-Type:

[source,http,options="nowrap"]
----
PUT /?b=bravo&c=charlie HTTP/1.1
Accept: application/json
Host: localhost:8080
Content-Type: application/x-www-form-urlencoded

b=bravo&c=charlie
----

By contrast, the curl, HTTPie, and request body snippets are correct with no body being sent:

[source,bash]
----
$ curl 'http://localhost:8080/?b=bravo&c=charlie' -i -X PUT \
    -H 'Accept: application/json'
----
[source,bash]
----
$ http PUT 'http://localhost:8080/?b=bravo&c=charlie' \
    'Accept:application/json'
----
[source,options="nowrap"]
----

----

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions