We are having issue with OData API for an Azure search index that it is not returning metadata. We are able to perform OData based queries but not able to access metadata
Our expectation was that Odata end point
https://search-service-name.search.windows.net/indexes/index-name?api-version=2019-05-06&api-key=XXXXXXXXXXX&odata.metadata=full
should return the metadata. Other end points we have tried
https://search-service-name.search.windows.net/indexes('index-name')/$metadata?api-version=2019-05-06&api-key=XXXXXXXX&odata.metadata=full
If we use the api-key set up for querying, we get error
{
"error": {
"code": "",
"message": "Authorization failed."
}
}
Using Admin key as api-key, error returned is { "Message": "The given API key is not permitted in the URI query string." }
Has anyone else been able to get full OData API working with Azure search Index?
Thanks
Both odata.metadata=full
and api-key
need to be passed as HTTP headers, not query-string parameters. api-key
is its own header, while odata.metadata=full
is a parameter that should be part of the Accept
header, like this: application/json;odata.metadata=full
.
That said, unless you're trying to use Azure Search with an OData-enabled client for which you can't change the code, you shouldn't need the full OData metadata. At most you'd need odata.metadata=minimal
to include type annotations for parts of the REST API that use inheritance (for example, when configuring analyzers, skills, or change/deletion detection policies for indexers).