POST Request in Jetty Client 9.X

6

I'm using Jetty Client to request a API Web , until recently everything was ok, but I felt the need to send data via POST.

Problem
In Jetty's documentation says that POST request data should be passed by the param("chave", "valor") method, however the data is being passed via query-string

Request r = client.POST(url).param("access_token", accessToken);

The request is being in this format:
api.web.com/?access_token=1727020009.2da29da.ed9bdd6cc095430e8f1640bbeeas

I also checked the wireshark message

Has anyone ever encountered this problem?

    
asked by anonymous 05.08.2015 / 17:30

1 answer

0

So the Jetty documentation to date is incorrect, followed the same logic that the Jersey implements, data via POST , must be encapsulated in a formulário .

In Jetty the passing of Post data is as follows:

Request r = client.newRequest("http://localhost")
.method(HttpMethod.POST)
.path("/post.php?as=a")
.param("access_token", accessToken);
Fields fields = new Fields();
fields.add("post1", "valorpost1");
FormContentProvider content = new FormContentProvider(fields);
r.content(content);
r.send()

That has as the return:

[POST] => Array
    (
        [asd] => asdasd
    )

[GET] => Array
    (
        [access_token] => asdasdasdsd
    )

This was noticed when I entered the api doc and I noticed that the param method in Request is not to enqueue data POST but GET as stated in other documentation

BelowwehavetheJettydocumentationstatingthatthepostshouldbepassedviaparam

    
05.08.2015 / 21:06