简体   繁体   中英

How to post event with metadata to stream through HTTP API

I'm using EventStore and want to post a message (event) to it. I use the HTTP API for testing purposes. I've managed to post the event itself, with an event type specified, but I can't figure out how to specify metadata for my event. (and I must provide this metadata because my consuming application on the other side expects it).

This is what my HTTP request looks like:

Content-Type: application/json ES-EventType: My.own.event.type POST http://10.0.75.2:2113/web/index.html#/streams/foobar { "props": "andvalues" }

Do I specify metadata in the body in through headers? I can't find much docs about this, only the official that doesn't mention it.

The documentation mentions the full schema for an event being written. It looks like this:

[
    {
      "eventId"    : "string",
      "eventType"  : "string",
      "data"       : "object",
      "metadata"   : "object"
    }
]

For example:

[
  {
    "eventId": "fbf4a1a1-b4a3-4dfe-a01f-ec52c34e16e4",
    "eventType": "event-type",
    "data": { "a": "1" },
    "metadata": { "b": "2" }
  }
]

Note that it's an array, and that you must pass content-type as application/vnd.eventstore.events+json

Check this page , scroll to Event Store Events Media Type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM