-4

I have a third party API which needs content body in a http GET request and doesn't accept any other forms of input.I cant make any changes to this API and the owners are not taking change requests to the API. I know that this is a bad design and all but is there any way this could be done ? I have tried apache httpurlconnection and java url apis, but haven't been able to achieve the same.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Mr A
  • 27
  • 1
  • 5

1 Answers1

0

You need to use the below

public class HttpGetWithBody extends HttpEntityEnclosingRequestBase {

    @Override
    public String getMethod() {
        return "GET";
    }
}

HttpGetWithBody getWithBody = new HttpGetWithBody ();
getWithBody.setEntity(y(new ByteArrayEntity(
            "<SOMEPAYLOAD FOR A GET ???>".toString().getBytes("UTF8"))););
getResponse = httpclient.execute(getWithBody );

Import needed will be org.apache.http.client.methods.HttpEntityEnclosingRequestBase;

Ramachandran.A.G
  • 4,788
  • 1
  • 12
  • 24