question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GET method with @RequestLine @Param containing a question mark (/index.php?/) is converted to POST

See original GitHub issue

Hi. I came from https://github.com/OpenFeign/feign/issues/838 This has been fixed in https://github.com/OpenFeign/feign/pull/841

When i use the code from last comment:

@RequestLine(value = "GET /index.php?/api/v2/get_tests/{runId}")
    @Headers({
            "Content-Type: application/json",
            "Accept: */*",
    })
    Test[] getTestsByRunId(@Param(value = "runId") Integer runId);

i get the following error even though i use the GET method (hide server & Authorization string):

 [feign.Logger] ---> GET https://testrail.server.domen/testrail/index.php?/api/v2/get_tests/999 HTTP/1.1
[feign.Logger] Accept: */*
[feign.Logger] Authorization: Basic *hidden*
[feign.Logger] Content-Length: 13
[feign.Logger] Content-Type: application/json
[feign.Logger] 
[feign.Logger] {"runId":999}
[feign.Logger] ---> END HTTP (13-byte body)
[feign.Logger] <--- HTTP/1.1 404 File Not Found (974ms)
[feign.Logger] connection: keep-alive
[feign.Logger] content-length: 61
[feign.Logger] content-type: application/json; charset=utf-8
[feign.Logger] date: Thu, 03 Oct 2019 08:58:19 GMT
[feign.Logger] server: nginx/1.10.2
[feign.Logger] x-powered-by: PHP/5.4.45
[feign.Logger] 
[feign.Logger] {"error":"Unsupported HTTP method \"post\" for this action."}
[feign.Logger] <--- END HTTP (61-byte body)
```

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kdavisk6commented, Dec 27, 2019

I found the issue. The code we have was only evaluating template variables on a query string when they are present in the query parameter value part of the expression. We were not accounting for expressions that occur in the query parameter name portion, which is how query expressions presented in this issue get processed. This is due to the fact that we expect name=value pairs on a query string when parsing.

I will work on a fix and present a PR shortly.

0reactions
iNTEAMcommented, Nov 18, 2019

@kdavisk6 i use this example but get an error:

Content-Type header invalid (use Content-Type: application\/json)

i try next scenarios but get same error:

  1. Use POST
  2. update versions of all feign libraries

Here is my API:

public interface CasesControllerApi {
    @RequestLine(value = "GET /index.php?/api/v2/get_tests/{runId}")
    @Headers({"Content-Type: application/x-www-form-urlencoded"})
    Test[] getTestsByRunId(@Param(value = "runId") Integer runId);
}

my feignBuilder:

        feignBuilder = Feign.builder()
                .encoder(new FormEncoder(new JacksonEncoder(objectMapper)))
                .decoder(new JacksonDecoder(objectMapper))
                .logger(new Slf4jLogger());

Log:

---> GET https://myurl.com/testrail/index.php?/api/v2/get_tests/999 HTTP/1.1
Content-Length: 9
Content-Type: application/x-www-form-urlencoded; charset=UTF-8

runId=999
---> END HTTP (9-byte body)
<--- HTTP/1.1 400 Bad Request (771ms)
connection: keep-alive
content-length: 77
content-type: application/json; charset=utf-8
server: nginx/1.10.2
x-powered-by: PHP/5.4.45

{"error":"Content-Type header invalid (use Content-Type: application\/json)"}
<--- END HTTP (77-byte body)
Read more comments on GitHub >

github_iconTop Results From Across the Web

PHP get the parameters that are put after the question mark in ...
The $_GET array is an array with all the arguments passed in the URL. You can use $_GET['param1']; to get the value of...
Read more >
Query string - Wikipedia
A query string is a part of a uniform resource locator (URL) that assigns values to specified parameters. A query string commonly includes...
Read more >
Hypertext Transfer Protocol -- HTTP/1.0 - W3C
A client establishes a connection with a server and sends a request to the server in the form of a request method, URI,...
Read more >
Why shouldn't a GET request change data on the server?
If I make a php service which inserts data in the database, and pass it parameters in the GET query string, why is...
Read more >
RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1
A client sends a request to the server in the form of a request method, URI, and protocol version, followed by a MIME-like...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found