# Unable to post data via ElasticLowLevelClient

**URL:** <https://discuss.elastic.co/t/unable-to-post-data-via-elasticlowlevelclient/274078>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [May 26, 2021, 2:42pm UTC](https://discuss.elastic.co/t/unable-to-post-data-via-elasticlowlevelclient/274078 "2021-05-26T14:42:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NeilRedfern](https://avatars.discourse-cdn.com/v4/letter/n/9f8e36/32.png) [@NeilRedfern](https://discuss.elastic.co/u/NeilRedfern)\
**Post date:** [May 26, 2021, 2:42pm UTC](https://discuss.elastic.co/t/unable-to-post-data-via-elasticlowlevelclient/274078/1 "2021-05-26T14:42:54Z")

</div>

Hello,

I'm attempting to add data into our Elastic cloud instance following the examples within the post [Exporting Azure Log data to the ELK stack with Azure Functions and Event Hubs](https://talkcloudlytome.com/elk-with-functions-event-hubs/)

However despite my best efforts I receive a 404 error when posting data. I've attempted the following:

1. Using an API Key via both basic and ApiKey authentication
2. Retrieving a document from an existing index.

All of which result in a 404 error, does anyone have any suggestions of what I'm missing?

For completeness I've included the code below:

```auto
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Elasticsearch.Net;

namespace ElasticLink
{
    class Program
    {
        static async Task Main(string[] args)
        {
            var exceptions = new List<Exception>();

            var elasticsearchIndex = "winlogbeat-7.9.2-2020.12.18-000001";
            var elasticsearchAddress = "https://xxxx.eastus2.azure.elastic-cloud.com:9243";
            var settings = new ConnectionConfiguration(new Uri(elasticsearchAddress));

            string apibase64 = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes("/"));

            //settings.ApiKeyAuthentication(new ApiKeyAuthenticationCredentials(apibase64));
           // settings.ApiKeyAuthentication("/");
            //settings.BasicAuthentication("elastic", "/");
            var client = new ElasticLowLevelClient(settings);
            
            var foo = client.Get<StringResponse>("winlogbeat-7.9.2-2020.12.18-000001", "\tMMMcgHkBHhgQL_FRFr39");

            try
            {
                //string messageBody = Encoding.UTF8.GetString(eventData.Body.Array, eventData.Body.Offset, eventData.Body.Count);

                string messageBody = "Hello";
                // you probably wouldn't want this log message in a production instance, but we'll keep it here for our testing purposes
                //log.LogInformation($"Raw Data From Function: {messageBody}");
                var response = client.Index<StringResponse>(elasticsearchIndex, PostData.String(messageBody));
                if (!response.Success)
                {
                    throw response.ApiCall.OriginalException;
                }

                await Task.Yield();
            }
            catch (Exception e)
            {
                // We need to keep processing the rest of the batch - capture this exception and continue.
                // Also, consider capturing details of the message that failed processing so it can be processed again later.
                exceptions.Add(e);
            }
            // Once processing of the batch is complete, if any messages in the batch failed processing throw an exception so that there is a record of the failure.

            if (exceptions.Count > 1)
                throw new AggregateException(exceptions);

            if (exceptions.Count == 1)
                throw exceptions.Single();
		}
    }
}

```

Thanks

Neil

---

<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:** [June 23, 2021, 2:43pm UTC](https://discuss.elastic.co/t/unable-to-post-data-via-elasticlowlevelclient/274078/2 "2021-06-23T14:43:00Z")

</div>

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