Oct 07, 2024
Request options
The API client methods accept additional parameters for adding headers or query parameters.
If you want to customize the client itself, see Customize clients.
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
23
24
25
26
27
28
29
package com.algolia.example
import com.algolia.client.api.SearchClient
import com.algolia.client.model.search.*
import com.algolia.client.transport.RequestOptions
suspend fun main() {
val client = SearchClient(
"ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY",
)
client.search(
SearchMethodParams(
listOf(
SearchForHits(
indexName = "ALGOLIA_INDEX_NAME",
query = "SEARCH_QUERY",
)
)
),
RequestOptions(
// Add a custom HTTP header to this request
headers = mapOf("extra-header" to "greetings")
// Add query parameters to this request
urlParameters = mapOf("queryParam" to "value")
)
)
}
Query parameters only apply to methods that accept them,
such as GET
requests.
Reference
headers
|
type: Map<String,Any>
Additional headers as key-value pairs to send with this request. |
urlParameters
|
type: Map<String,Any>
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?