Can I Do An Http Get And Include A Body Using Httpurlconnection?
Solution 1:
It is not possible to send content for an HTTP GET using HttpURLConnection
. By setting setDoOutput(true)
on an HttpURLConnection
the verb is forced to be POST.
The documentation for the REST API I was using described a JSON body for the endpoint in question, but URL parameters were accepted.
Solution 2:
It might not be possible through HttpUrlConnection, although you might be able to do it through another APIs BUT, if you have to do it that way chances that you are doing something wrong in your architecture are high because it goes against the basic usage of GET Http Method and different problems might arise like: If you ever try to take advantage of caching, Proxies are not going to look in the GET body to see if the parameters have an impact on the response. It's not a good implementation based on standard practices and it could cause problems with some browsers / services.
Take a look at this question for more information.
Hope this helps.
Regards!
Post a Comment for "Can I Do An Http Get And Include A Body Using Httpurlconnection?"