---
title:  GET /gemfire-api/v1/queries/adhoc?q=&lt;OQL-statement&gt;
---

<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

Run an unnamed (unidentified), ad-hoc query passed as a URL parameter.

## Resource URL

``` pre
http://<hostname_or_http-service-bind-address>:<http-service-port>/gemfire-api/v1/queries/adhoc?q=<OQL-statement>
```

## Parameters

<table>
<colgroup>
<col width="33%" />
<col width="33%" />
<col width="33%" />
</colgroup>
<thead>
<tr class="header">
<th>Parameter</th>
<th>Description</th>
<th>Example Values</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>q</td>
<td><strong>Required.</strong> OQL query statement.
<div class="note note">
**Note:**
<p>Since the query string is passed in the URL, the OQL must be URL-encoded. Some HTTP clients such as Web browsers will automatically encode URLs; however, if you are not using one of those clients, you will need to URL encode the query string yourself.</p>
</div></td>
<td><code class="ph codeph">SELECT o FROM /orders o WHERE o.quantity &gt; 2 AND               o.totalprice &gt; 110.00</code>
<p>(or URL encoded: <code class="ph codeph">SELECT%20o%20FROM%20%2Forders%20o%20WHERE%20o.quantity%20%3E%202%20AND%20o.totalprice%20%3E%20110.00</code>)</p>
<p><code class="ph codeph">SELECT * FROM /customers</code></p>
<p>(or URL encoded: <code class="ph codeph">SELECT%20*%20FROM%20/customers</code>)</p></td>
</tr>
</tbody>
</table>

## Example Request

``` pre
curl -i "http://localhost:8080/gemfire-api/v1/queries/adhoc?q=select%20*%20%20from%20/customers"
```

## Example Success Response

``` pre
Response Payload: application/json

200 OK
Content-Length: <#-of-bytes>
Content-Type: application/json
[
    {
        "firstName":  "John",
         "lastName":  "Doe",
         "customerId": 101,
    },
    {
         "firstName":  "Jane",
         "lastName":  "Doe",
         "customerId": 102,
    },
    {
       ....
    }
]
```

## Error Codes

<table>
<colgroup>
<col width="50%" />
<col width="50%" />
</colgroup>
<thead>
<tr class="header">
<th>Status Code</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>401 UNAUTHORIZED</td>
<td>Invalid Username or Password</td>
</tr>
<tr>
<td>403 FORBIDDEN</td>
<td>Insufficient privileges for operation</td>
</tr>
<tr class="odd">
<td>500 INTERNAL SERVER ERROR</td>
<td>Error encountered at <%=vars.product_name%> server. Check the HTTP response body for a stack trace of the exception. Some possible exceptions include:
<ul>
<li>A function was applied to a parameter that is improper for that function!</li>
<li>Bind parameter is not of the expected type!</li>
<li>Name in the query cannot be resolved!</li>
<li>The number of bound parameters does not match the number of placeholders!</li>
<li>Query is not permitted on this type of region!</li>
<li>Query execution time is exceeded max query execution time (gemfire.Cache.MAX_QUERY_EXECUTION_TIME) configured!</li>
<li>Data referenced in from clause is not available for querying!</li>
<li>Query execution gets canceled due to low memory conditions and the resource manager critical heap percentage has been set!</li>
<li>Server has encountered an error while executing Adhoc query!</li>
</ul></td>
</tr>
</tbody>
</table>


