Android Question [solved] okhttp not removing headers in a POST request

Discussion in 'Android Questions' started by DonManfred, Jun 28, 2015.

  1. DonManfred

    DonManfred Expert Licensed User

    Code:
    Sub GetThumbnail(path As String, format As String, size As String)
        
    Dim job As HttpJob
        job.Initialize(
    "getthumbnail",Me)
        job.Tag = 
    path
        job.PostString(mApiV2urlContent&
    "files/get_thumbnail","")
        job.GetRequest.SetHeader(
    "Authorization""Bearer "&mAccessToken)
        job.GetRequest.SetHeader(
    "Dropbox-API-Arg"$"{"path":"${path}","format":"${format}","size":"${size}"}"$)
        
    'job.GetRequest.SetContentEncoding("text/plain")
        job.GetRequest.RemoveHeaders("Content-Type")
    End Sub
    I would expect to get the Content-Type header removed. But i get an error told from Dropbox

    I´m using httputils2 2.10 and okhttp lib 0.95
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    The problem is that the content type header is only added later. You can force it to be empty with:
    Code:
    job.GetRequest.SetContentType("")
     
    DonManfred likes this.
  3. DonManfred

    DonManfred Expert Licensed User

    Great. Thank you. That fixes the issue with Dropbox.

    StepForward: +1 :D
     
    Erel likes this.
Loading...