title: retrofit 2 : pass dynamic header along with body
body: <p>I want to pass Header and Body dynamically to a Web Api. So, I have implemented as below:</p>
  
  <pre><code>public interface NotificationService {
      @POST("user/update/notification")
      Call&lt;JsonObject&gt; notification(@Header("Authorization") String authorization, @Body NotificationRequest notificationRequest);
  }
  </code></pre>
  
  <p>And using this as,</p>
  
  <pre><code>showProgressDialog();
  NotificationRequest notificationRequest = new NotificationRequest(checked ? ApiConstants.IS_ON : ApiConstants.IS_OFF, getUserId());
  NotificationService notificationService = ApiFactory.provideNotificationService();
  Call&lt;JsonObject&gt; call = notificationService.notification(getAuthorizationHeader(), notificationRequest);
  call.enqueue(new Callback&lt;JsonObject&gt;() {
              @Override
              public void onResponse(Call&lt;JsonObject&gt; call, Response&lt;JsonObject&gt; response) {
                  logDebug(SettingsFragment.class, response.body().toString());
                  hideProgressDialog();
              }
  
              @Override
              public void onFailure(Call&lt;JsonObject&gt; call, Throwable t) {
                  hideProgressDialog();
              }
          });
  </code></pre>
  
  <p>But this way, I am not getting null response (<code>response.body()</code> is null).</p>
  
  <p>Can anyone suggest how to pass Dynamic Header and Body together ?</p>
  
  <p><strong>Note:</strong> I went through <a href="https://futurestud.io/tutorials/retrofit-add-custom-request-header" rel="nofollow">this</a> tutorial but didn't found the way to pass both.</p>