因此,我正在尋求向我們的api請求登錄用戶,但是有一部分在改進2方法中編碼,即使其設置爲encoded = true
。的基本網址爲https://testapi.test.ie
我通過爲serverext
的參數設置,即使在encoded = true
導致請求主體是後mdc.php?action=
但是:https://testapi.test.ie/mdc.php%3Faction=login_user&ts=1482924232742
,我要求它:https://testapi.test.ie/mdc.php?action=login_user&ts=1482924232742
所以我能看到的問題是?
符號。下面是我的改造方法,如果任何人都可以在這方面幫助我將不勝感激,以達到正確的改進2編碼中的特殊字符問題
@retrofit2.http.POST("/{serverext}login_user&ts={timestamp}")
@retrofit2.http.Multipart
Call<LoginResponseModel> loginUser(@retrofit2.http.Path(value = "serverext", encoded = true) String server,
@retrofit2.http.Part(Constants.USER) String username,
@retrofit2.http.Part(Constants.PASS) String password,
@retrofit2.http.Path("timestamp") Long timestamp);
如果我更改爲這種格式,則請求形成正確,但我收到來自API的錯誤響應,因爲無效憑證不正確,因爲憑證是正確的。我認爲它需要@ Path而不是@ Query。我從1.9升級,它是@ Path並正常工作。這種編碼特殊字符是retrofit2還是okhttp3的限制? –
我不知道編碼,但你用API不正確。你能檢查你的要求嗎?什麼是不正確的? –
我目前正在從1.9升級到2.0,在1.9我們使用了像這樣的@pi(「/ {server} login_user&ts = {timestamp}」) @Multipart void loginUser(@Path(value =「server」, (Constants.USER)字符串用戶名, @Part(Constants.PASS)字符串密碼, @Path(「timestamp」)長時間戳,回調回調);'這工作正確地進行測試時,服務器的測試結果是憑據是正確的。 –