title: How to pass a value to the retrofit url for a post request
body: <p>I am trying to make a post request with retrofit to rate a movie with <a href="https://developers.themoviedb.org/3/movies/rate-movie" rel="nofollow noreferrer">https://developers.themoviedb.org/3/movies/rate-movie</a>. The thing is, the url itself takes on the movie's id like this:</p>
  <pre><code>@POST(&quot;/movie/{id}/rating?api_key=${API_KEY}&quot;)
  fun postRating(@Path(&quot;id&quot;) id:Int): Call&lt;RatingResponse&gt;
  </code></pre>
  <p>And then I need to also pass my rating value to make the post request. I did that through here (I think):</p>
  <p>Remote data source:</p>
  <pre><code>interface RatingCallBack {
          fun onSuccess()
          fun onError(message: String?)
      }
  
      fun postRating(rating: Int, ratingCallback: RatingCallBack){
          val service = RetrofitService.instance
              .create(MovieService::class.java)
  
          val call = service.postRating(rating)
  
          call.enqueue(object : Callback&lt;RatingResponse?&gt; {
              override fun onResponse(
                  call: Call&lt;RatingResponse?&gt;,
                  response: Response&lt;RatingResponse?&gt;
              ) {
                  if (response.isSuccessful) {
                      Log.d(&quot;d&quot;,&quot;d&quot;)
                  } else {
                      Log.d(&quot;d&quot;,&quot;d&quot;)
                  }
              }
              override fun onFailure(call: Call&lt;RatingResponse?&gt;, t: Throwable) {
                  Log.d(&quot;d&quot;,&quot;d&quot;)
              }
          })
  
      }
  </code></pre>
  <p>The viewmodel:</p>
  <pre><code>class RatingViewModel constructor(
     private val remoteDataSource: MovieRemoteDataSource
  ): ViewModel() {
  
  
     val ratingSuccess = MutableLiveData&lt;Boolean&gt;()
     val ratingFailedMessage = MutableLiveData&lt;String?&gt;()
  
     fun postRating(rating:Int){
         remoteDataSource.postRating(rating, object: MovieRemoteDataSource.RatingCallBack{
             override fun onSuccess(){
                 ratingSuccess.postValue(true)
             }
             override fun onError(message:String?){
                 ratingSuccess.postValue(false)
                 ratingFailedMessage.postValue(message)
             }
         })
     }
  }
  </code></pre>
  <p>And in the fragment (I'll pass the user's rating later if this works):</p>
  <pre><code>binding.btRating.setOnClickListener {
     viewModel.postRating(2)
  }
  </code></pre>
  <p>The thing is, I don't know where I'm supposed to pass the movie's id so that I can pass it to the url in retrofit since the movie's id is something I get through a bundle I send to my fragment from my activity like this:</p>
  <pre><code>val idInt = arguments?.getInt(&quot;Id&quot;)
  </code></pre>
  <p>Any ideas? Thank you.</p>