No error message but empty response body when querying vectors using the API in C#

Hello, I’m using C# and the API to upsert and query vectors. I’ve managed to sucessfully upsert vectors to the index however I can’t query them even though I get a successful response from the server as shown here :

StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
grpc-status: 12
date: Sun, 30 Jul 2023 17:21:08 GMT
server: envoy
connection: close
content-length: 0

Here is the code I’m using to query the vectors :

public async void QueryVectors(string vector)
            var client = new HttpClient();
            var request = new HttpRequestMessage
                Method = HttpMethod.Post,
                RequestUri = new Uri("Query URL of my index"),
                Headers =
                    { "accept", "application/json" },
                    { "Api-Key", "My API key" },
                Content = new StringContent("{\"namespace\":\"default-namespace\",\"topK\":1,\"includeValues\":\"false\",\"includeMetadata\":\"true\",\"vector\":\"" + "[" + vector + "]" + "}", Encoding.UTF8, "application/json")
                    Headers =
                        ContentType = new MediaTypeHeaderValue("application/json")
            using (var response = await client.SendAsync(request))
                var body = await response.Content.ReadAsStringAsync();

The code returns an empty body, any suggestions ?

Hi, @epteak

Firstly, looking at your response headers, there’s an error code ‘grpc-status: 12’. This is a gRPC error code, which stands for ‘UNIMPLEMENTED’. It means that the server understands the request, but it’s not capable of fulfilling it because the functionality isn’t implemented.

Secondly, looking at your query code, it seems like there might be an issue with how you’re representing the vector in your request body. Vectors are typically represented as arrays of numbers, but in your code, it seems like you’re treating the vector as a string. This could be causing the issue.

To correctly represent the vector, you should treat the vector as an array of numbers, not a string. Like so:

csharpCopy code

Content = new StringContent("{\"namespace\":\"default-namespace\",\"topK\":1,\"includeValues\":\"false\",\"includeMetadata\":\"true\",\"vector\":" + vector + "}", Encoding.UTF8, "application/json")

Here, vector should be a JSON string representing an array of numbers, like "[1.0, 2.0, 3.0]".

Another possibility that comes to mind is that the URL might not be correct.

  • When the path following Pinecone’s service domain ( is not valid, an HTTP 200 OK with an empty Body appears to be returned. (This assumes that the Api-Key is correctly set). In this case, even if the value of the POST Body is an invalid string (text/plain), an HTTP 200 is still returned.
  • If the URL is correct and there is a problem with the Body, HTTP 400 should be returned.
  • You mentioned that the index update was successful, but can you confirm that the vectors have been added on the following screen as well?

@epteak If you’re interested, you can give Pinecone.NET a try, unless your TFM is below net7.0 or you require a different/custom behavior.

Hello @dra
Thank you very much for your answer since it allowed me to fix the problem.
The issue was indeed related to the path following Pinecone’s service domain. The path was https://“my index name” instead of https://“my index name”