0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Android開発でRetrofit2初心者がつまずいたところ

0
Posted at

Android開発初心者がRetorofit2でつまずいたところ

結論

エンドポイントの指定の仕方が間違っていた

状況

Retrofit2のPUTメソッドで処理を実行したら文字列を返すように実装したが、なぜか404が返ってくる

解決策

指定したエンドポイント文頭の/を削除した

変更前hoge.kt
@PUT("/fuga/{fugi}")
    fun func(
        @Path("fugi")
    ):Call<Unit>
変更後hoge.kt
@PUT("fuga/{fugi}")
    fun func(
        @Path("fugi")
    ):Call<Unit>

まとめ

どこが違うのか見つけるのに3時間くらいかけてエンドポイントの指定方法が違っていることに気づいた。同じようにつまずいている人の解決につながってほしいのと、自分の備忘録としてqiitaに残しておくことにする。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?