---
title:  POST /gemfire-api/v1/queries?id=&lt;queryId&gt;&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.
-->

Create (prepare) the specified parameterized query and assign the corresponding ID for lookup.

## Resource URL

``` pre
http://<hostname_or_http-service-bind-address>:<http-service-port>/gemfire-api/v1/queries?id=<queryId>&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>id</td>
<td><strong>Required.</strong> Unique identifier for the named parameterized query.</td>
<td>selectCustomers</td>
</tr>
<tr class="even">
<td>q</td>
<td><strong>Required.</strong> OQL query statement. Use doublequotes to surround the OQL query statement.</td>
<td><pre class="pre"><code>&quot;SELECT o FROM /orders o WHERE o.quantity &gt; $1 AND o.totalprice &gt; $2&quot;</code></pre></td>
</tr>
</tbody>
</table>

**Note:**
For this release, you cannot specify the query string inside the request body (as JSON). You must specify the query as a URL parameter.

## Example Request

``` pre
POST /gemfire-api/v1/queries?id=selectOrders&q="SELECT o FROM /orders o WHERE o.quantity > $1 AND o.totalprice > $2"
Accept: application/json
```

## Example Success Response

``` pre
Response Payload: null

201 CREATED
Location: http://localhost:8080/gemfire-api/v1/queries/selectOrders
```

## 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>400 BAD REQUEST</td>
<td>Query ID not specified or malformed OQL statement</td>
</tr>
<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>
<td>409 CONFLICT</td>
<td>QueryId already assigned to another query</td>
</tr>
<tr class="even">
<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.
<ul>
<li>Query store does not exist!</li>
</ul></td>
</tr>
</tbody>
</table>


