7


I started to work with android.app.DownloadManager and faced a problem.
By default, DM sending HTTP GET request to download file:

GET http://www.example.com/getfile HTTP/1.1
Cookie: id=sdfsdf;Max-Age=10800000;Path=/
Host: ___
Connection: Keep-Alive
User-Agent: AndroidDownloadManager Paros/3.2.13
Content-length: 0

But I need to send some data in request(e.g. json string)
Are there any ways to send HTTP POST request in DownloadManager

Grekov Serg
  • 251
  • 3
  • 11
  • 1
    if your data is not too important, you can add your data in the get request (while encoding special chars) like this : http://www.example.com/getfile?id=xxx&data=%e9l%e9ment%20encod%e9 – Darkendorf Jul 03 '12 at 09:41
  • Thanks, I knew that, but the requirement is to send data in the body of request. – Grekov Serg Jul 04 '12 at 09:50

1 Answers1

3

While waiting for another more accurate answer :

I don't think you can add data to this request since, as you said it, it's a GET request and not POST.

Maybe this thread can give you a hint on another way to achieve what you want if the Download-Manager is not absolutely required : How do download a file with login using HttpURLConnection

Community
  • 1
  • 1
Darkendorf
  • 463
  • 11
  • 28
  • 1
    I'am actually dropped this method, and made downloading with AsyncTask. But it's still very wierd, that developers didn't made that simple option to the DM, which, I guess, very commonly used. – Grekov Serg Jul 05 '12 at 13:24