4

I have a AQL query that looks like this

items.find(
    {
        "path":{"$match":"product/*"},
        "size":{"$gt" : "10000"},
        "type":{"$eq" : "file"}

    }
)

and my java HttpClient looks like this

    String url = "http://restEndpoint/";
    HttpClient client = HttpClientBuilder.create().build();
    HttpPost request = new HttpPost(url);

    request.addHeader("User-Agent", USER_AGENT);
    request.addHeader("Content-Type", "text/plain");

   /*how do I insert the data here*/
    request.setEntity();

    HttpResponse response = client.execute(request);

I'm wondering how do I insert the query in request.setEntity as it only accepts HttpEntity

GlennV
  • 3,471
  • 4
  • 26
  • 39
Adam Novakovi
  • 759
  • 1
  • 9
  • 18

1 Answers1

4

Looks like you're using Apache httpcomponents.

There is a tutorial that explains how to use entities.

There are various entity classes that you can use to wrap your content in, e.g. for String content you can use something like this:

StringEntity myEntity = new StringEntity("important message", ContentType.create("text/plain", "UTF-8"));

Just make sure you use the correct mimetype.

The javadoc about the available entity classes is available here.

GlennV
  • 3,471
  • 4
  • 26
  • 39