# Elastic.Clients.Elasticsearch .NET client - calling Vector tile search API

**URL:** <https://discuss.elastic.co/t/elastic-clients-elasticsearch-net-client-calling-vector-tile-search-api/341422>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [August 23, 2023, 3:58am UTC](https://discuss.elastic.co/t/elastic-clients-elasticsearch-net-client-calling-vector-tile-search-api/341422 "2023-08-23T03:58:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jarrod](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@Jarrod](https://discuss.elastic.co/u/Jarrod)\
**Post date:** [August 23, 2023, 3:58am UTC](https://discuss.elastic.co/t/elastic-clients-elasticsearch-net-client-calling-vector-tile-search-api/341422/1 "2023-08-23T03:58:22Z")

</div>

I am trying to call the Vector tile search API using the new v8 .NET client but receiving an exception. Specifically 8.9.2 as of writing.

I understand it doesn't have official support in the client, but it appears I should be able to call it via a low level call.

The exception info I am receiving is this:

```auto
Unsuccessful (200) low level call on GET: /jarrod-development/_mvt/Geometry/1/1/1
 Exception: Request failed to execute. Call: Status code 200 from: GET /jarrod-development/_mvt/Geometry/1/1/1

```

```auto
# Request:
<Request stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on TransportConfiguration to force it to be set on the response.>

```

My code looks like this:

```auto
var path = $"/jarrod-development/_mvt/Geometry/{dto.Zoom}/{dto.X}/{dto.Y}";
var results = await _elasticClient.Transport.RequestAsync<DynamicResponse>(HttpMethod.GET, path, cancellationToken: ct);

```

Where "Geometry" is the geo field name on my document.

I have tried the following options:  
Changing the HttpMethod to POST  
Changing the return type to `BytesResponse`  
Disabling direct streaming when creating the Client, `settings.DisableDirectStreaming();`  
Not using debug mode, ie. `settings.EnableDebugMode();`

I thought my URL/path may be wrong, but if I run this manually in the Elastic Cloud console I receive a result:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/8/08d6e1710275387ed364e9c8e223458b2a5dad79.png)

Assistance appreciated, thanks

---

<div class="post-metadata">

**Author:** ![flobernd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flobernd/32/124877_2.png) [@flobernd](https://discuss.elastic.co/u/flobernd)\
**Post date:** [August 23, 2023, 9:13am UTC](https://discuss.elastic.co/t/elastic-clients-elasticsearch-net-client-calling-vector-tile-search-api/341422/2 "2023-08-23T09:13:23Z")

</div>

Hi!

Could you please post the request and response JSON strings (you find them in the `exception.ApiCallDetails` object; direct streaming needs to be disabled).

For me it seems like the call itself succeeded (200 response), but something went wrong afterwards.

---

<div class="post-metadata">

**Author:** ![Jarrod](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@Jarrod](https://discuss.elastic.co/u/Jarrod)\
**Post date:** [August 24, 2023, 12:16am UTC](https://discuss.elastic.co/t/elastic-clients-elasticsearch-net-client-calling-vector-tile-search-api/341422/3 "2023-08-24T00:16:06Z")

</div>

@flobernd Thanks for your reply!

I can not see a request property but there is a response:  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/b/3bea3d0d34c05a42bf1c62f878192ba8cda90334.png)

The response is in bytes, which I would expect if it's returning a binary Mapbox vector tile. But I notice `HasExpectedContentType` is false.

Could my `RequestAsync<T>` argument be incorrect? I have tried both BytesResponse and DynamicResponse.

---

<div class="post-metadata">

**Author:** ![flobernd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flobernd/32/124877_2.png) [@flobernd](https://discuss.elastic.co/u/flobernd)\
**Post date:** [August 24, 2023, 7:28am UTC](https://discuss.elastic.co/t/elastic-clients-elasticsearch-net-client-calling-vector-tile-search-api/341422/4 "2023-08-24T07:28:17Z")

</div>

I think we are on the right track 🙂

You can provide the expected MIME type like this:

```csharp
var results = await client.Transport.RequestAsync<BytesResponse>(Elastic.Transport.HttpMethod.GET, path, cancellationToken: ct, requestParameters: new DefaultRequestParameters
{
	RequestConfiguration = new RequestConfiguration
	{
		Accept = "application/vnd.mapbox-vector-tile"
	}
});

```

---

<div class="post-metadata">

**Author:** ![Jarrod](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@Jarrod](https://discuss.elastic.co/u/Jarrod)\
**Post date:** [August 25, 2023, 12:49am UTC](https://discuss.elastic.co/t/elastic-clients-elasticsearch-net-client-calling-vector-tile-search-api/341422/5 "2023-08-25T00:49:07Z")

</div>

That worked, I am now exception free! Thanks

I am now having some trouble getting MapLibre to use the data, but I will probably open a new post for that.

MapLibre error:

```auto
q {status: 406, statusText: 'Not Acceptable', url: 'http://myUrl?zoom=2&x=0&y=1', body: Blob, message: 'AJAXError: Not Acceptable (406): http://myUrl?zoom=2&x=0&y=1'}

```

---

<div class="post-metadata">

**Author:** ![Jarrod](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@Jarrod](https://discuss.elastic.co/u/Jarrod)\
**Post date:** [September 5, 2023, 5:10am UTC](https://discuss.elastic.co/t/elastic-clients-elasticsearch-net-client-calling-vector-tile-search-api/341422/6 "2023-09-05T05:10:55Z")

</div>

I was able to resolve my data output issue. It was caused by the server. I had the response wrapped in an `Ok(result.Body)` Action Result.

Returning the `BytesResponse` in a `FileContentResult` resolved this issue.

Example:

```auto
        var result = await _queryHandler.VectorMapQuery(zoom, x, y, ct);
        HttpContext.Response.Headers.Add("Content-Type", "application/vnd.mapbox-vector-tile");
        return File(result.Body, "application/vnd.mapbox-vector-tile");

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 3, 2023, 5:10am UTC](https://discuss.elastic.co/t/elastic-clients-elasticsearch-net-client-calling-vector-tile-search-api/341422/7 "2023-10-03T05:10:57Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
