# How to map C# DateTime property to @timestamp field

**URL:** https://discuss.elastic.co/t/how-to-map-c-datetime-property-to-timestamp-field/327866
**Category:** Elasticsearch
**Tags:** language-clients
**Created:** [March 16, 2023, 3:14pm UTC](https://discuss.elastic.co/t/how-to-map-c-datetime-property-to-timestamp-field/327866 "2023-03-16T15:14:25Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![shelby](https://avatars.discourse-cdn.com/v4/letter/s/aeb1de/32.png) [@shelby](https://discuss.elastic.co/u/shelby)
#### Post date: [March 16, 2023, 3:14pm UTC](https://discuss.elastic.co/t/how-to-map-c-datetime-property-to-timestamp-field/327866/1 "2023-03-16T15:14:25Z")

</div>

I am trying unsuccessfully to se the c# client to bluk insert data into elasticsearch. the client connects successfully, however I now have an issue with the following code:

```csharp
var settings = client.ElasticsearchClientSettings;

settings.DefaultIndices.Add(typeof(HardwareData), "metrics-hardware-pristem");
var data = new HardwareData
{
    Id = 1,
    System_ErrorLevel = 1,
    timestamp = DateTime.Now
};
var timestampMemberInfo = typeof(HardwareData).GetMember("timestamp")[0];
client.ElasticsearchClientSettings.PropertyMappings.Add(timestampMemberInfo,
    new PropertyMapping() { Name = "@timestamp" });

var r2 = await client.IndexAsync(new IndexRequest<HardwareData>()
{
    Document = data
});
Console.WriteLine($"success={r2.IsSuccess()} : {r2.Id} => {r2.Result},{r2.DebugInformation}");

```

The output of DebugInformation is:

```json
{"type":"illegal_argument_exception","reason":"data stream timestamp field [@timestamp] is missing"}},"status":400}

```

From what I see there is lots of documentation on the NEST api, but very little on the current api, I was unable to find a working example.

What is the easiest way to map a property to a field (particularly the timestamp, since others should map automatically because they have the same name, I cannot use @timestamp as the name) ?

Additionally I tried using json attributes on the HardwareData class to specify the mapping, but that also failed with the same error.

---

<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: [April 13, 2023, 3:14pm UTC](https://discuss.elastic.co/t/how-to-map-c-datetime-property-to-timestamp-field/327866/2 "2023-04-13T15:14:55Z")

</div>

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