{"action":"created","issue":{"url":"https://api.github.com/repos/square/retrofit/issues/1886","repository_url":"https://api.github.com/repos/square/retrofit","labels_url":"https://api.github.com/repos/square/retrofit/issues/1886/labels{/name}","comments_url":"https://api.github.com/repos/square/retrofit/issues/1886/comments","events_url":"https://api.github.com/repos/square/retrofit/issues/1886/events","html_url":"https://github.com/square/retrofit/issues/1886","id":162786330,"number":1886,"title":"Path annotation arguments are required to be at the beginning of service method definition argument list","user":{"login":"wahweep","id":2067060,"avatar_url":"https://avatars.githubusercontent.com/u/2067060?v=3","gravatar_id":"","url":"https://api.github.com/users/wahweep","html_url":"https://github.com/wahweep","followers_url":"https://api.github.com/users/wahweep/followers","following_url":"https://api.github.com/users/wahweep/following{/other_user}","gists_url":"https://api.github.com/users/wahweep/gists{/gist_id}","starred_url":"https://api.github.com/users/wahweep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wahweep/subscriptions","organizations_url":"https://api.github.com/users/wahweep/orgs","repos_url":"https://api.github.com/users/wahweep/repos","events_url":"https://api.github.com/users/wahweep/events{/privacy}","received_events_url":"https://api.github.com/users/wahweep/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-06-28T21:00:42Z","updated_at":"2016-07-08T17:27:24Z","closed_at":null,"body":"Sorry if this is a requirement and I just missed reading it somewhere on the documentation site but it appears that `@Path` parameters have to be specified as arguments before `@QueryMap` arguments. (This may be true for other annotation arguments too but I ran into this problem with QueryMap) If this is not the case an AssertionError thrown. \r\n\r\nLooking through the code, retrofit2.RequestBuilder#addQueryParam seems to set the `relativeUrl` variable to null then retrofit2.RequestBuilder#addPathParam checks that relativeUrl is not null. When the QueryMap is the first parameter, relativeUrl has been set to null so this check causes the  AssertionError to be thrown.\r\n\r\nSorry if this is documented behavior somewhere and I missed it.\r\n\r\n```gradle\r\n...\r\ndependencies {\r\n    compile 'com.squareup.retrofit2:retrofit:2.1.0'\r\n    compile 'com.squareup.okhttp3:okhttp:3.3.1'\r\n    compile 'com.squareup.okhttp3:mockwebserver:3.3.1'\r\n}\r\n...\r\n```\r\n\r\nBelow you will find a test case that shows this error.\r\n```java\r\nimport okhttp3.ResponseBody;\r\nimport okhttp3.mockwebserver.MockResponse;\r\nimport okhttp3.mockwebserver.MockWebServer;\r\nimport org.junit.Rule;\r\nimport org.junit.Test;\r\nimport retrofit2.Response;\r\nimport retrofit2.Retrofit;\r\nimport retrofit2.Call;\r\nimport retrofit2.http.GET;\r\nimport retrofit2.http.Headers;\r\nimport retrofit2.http.Path;\r\nimport retrofit2.http.QueryMap;\r\n\r\nimport java.util.HashMap;\r\nimport java.util.Map;\r\n\r\nimport static org.junit.Assert.assertEquals;\r\n\r\npublic final class RetrofitBugTest {\r\n\t@Rule public final MockWebServer server = new MockWebServer();\r\n\r\n\tinterface Service {\r\n\t\t@GET(\"cards/classes/{className}\")\r\n\t\t@Headers(\"User-Agent: Test Case\")\r\n\t\tCall<ResponseBody> pathParamFirst(@Path(\"className\") String characterClass, @QueryMap()Map<String, Integer> params);\r\n\r\n\t\t@GET(\"cards/classes/{className}\")\r\n\t\t@Headers(\"User-Agent: Test Case\")\r\n\t\tCall<ResponseBody> pathParamLast(@QueryMap()Map<String, Integer> params, @Path(\"className\") String characterClass);\r\n\t}\r\n\r\n\t@Test public void pathParamsFirst() throws Exception {\r\n\t\tRetrofit retrofit = new Retrofit.Builder()\r\n\t\t\t\t.baseUrl(server.url(\"https://omgvamp-hearthstone-v1.p.mashape.com/\"))\r\n\t\t\t\t.build();\r\n\t\tService example = retrofit.create(Service.class);\r\n\r\n\t\tserver.enqueue(new MockResponse()\r\n\t\t\t\t.addHeader(\"Content-Type\", \"text/plain\"));\r\n\r\n\t\tString characterClass = \"Mage\";\r\n\t\tHashMap<String, Integer> searchParams = new HashMap<>();\r\n\t\tsearchParams.put(\"attack\", 4);\r\n\r\n\t\tCall<ResponseBody> call = example.pathParamFirst(characterClass, searchParams);\r\n\t\tResponse<ResponseBody> response = call.execute();\r\n\t\tassertEquals(\"application/json\", response.headers().get(\"Content-Type\"));\r\n\t}\r\n\r\n\t@Test public void queryParamsFirst() throws Exception {\r\n\t\tRetrofit retrofit = new Retrofit.Builder()\r\n\t\t\t\t.baseUrl(server.url(\"https://omgvamp-hearthstone-v1.p.mashape.com/\"))\r\n\t\t\t\t.build();\r\n\t\tService example = retrofit.create(Service.class);\r\n\r\n\t\tserver.enqueue(new MockResponse()\r\n\t\t\t\t.addHeader(\"Content-Type\", \"text/plain\"));\r\n\r\n\t\tString characterClass = \"Mage\";\r\n\t\tHashMap<String, Integer> searchParams = new HashMap<>();\r\n\t\tsearchParams.put(\"attack\", 4);\r\n\r\n\t\tCall<ResponseBody> call = example.pathParamLast(searchParams, characterClass);\r\n\t\tResponse<ResponseBody> response = call.execute();\r\n\t\tassertEquals(\"application/json\", response.headers().get(\"Content-Type\"));\r\n\t}\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/square/retrofit/issues/comments/231421093","html_url":"https://github.com/square/retrofit/issues/1886#issuecomment-231421093","issue_url":"https://api.github.com/repos/square/retrofit/issues/1886","id":231421093,"user":{"login":"wahweep","id":2067060,"avatar_url":"https://avatars.githubusercontent.com/u/2067060?v=3","gravatar_id":"","url":"https://api.github.com/users/wahweep","html_url":"https://github.com/wahweep","followers_url":"https://api.github.com/users/wahweep/followers","following_url":"https://api.github.com/users/wahweep/following{/other_user}","gists_url":"https://api.github.com/users/wahweep/gists{/gist_id}","starred_url":"https://api.github.com/users/wahweep/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wahweep/subscriptions","organizations_url":"https://api.github.com/users/wahweep/orgs","repos_url":"https://api.github.com/users/wahweep/repos","events_url":"https://api.github.com/users/wahweep/events{/privacy}","received_events_url":"https://api.github.com/users/wahweep/received_events","type":"User","site_admin":false},"created_at":"2016-07-08T17:27:24Z","updated_at":"2016-07-08T17:27:24Z","body":"Ok. Thanks for clarifying that for me."}}
{"actor":{"display_login":"wahweep"}}