Sep 20, 2024
Request options
The API client methods accept additional parameters for adding headers or query parameters.
For example:
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.algolia.example
import algoliasearch.api.SearchClient
import algoliasearch.config.RequestOptions
import algoliasearch.search.SearchParamsObject
import scala.concurrent.ExecutionContext.Implicits.global
@main
def main(): Unit = {
val client = SearchClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
client.searchSingleIndex(
indexName = "ALGOLIA_INDEX_NAME",
searchParams = Some(SearchParamsObject(query = Some("SEARCH_QUERY"))),
requestOptions = Some(RequestOptions(
// Add a custom HTTP header to this request
headers = Map("extra-header" -> "greetings"),
// Add query parameters to this request
queryParameters = Map("queryParam" -> "value")))
)
}
Query parameters only apply to methods that accept them,
such as GET
requests.
See the API reference for more information.
Reference
headers
|
type: Map[String,String]
Additional headers as key-value pairs to send with this request. |
queryParameters
|
type: Map[String,String]
Additional query parameters to send with this request. They only take effect with API operations that support query parameters. Otherwise, they’re ignored. |
Did you find this page helpful?