Cannot seem to be able to set stream metadata

I am trying to change the maxAge of events in a stream through the HTTP api. Is there any reason why this should not work?

POST http://127.0.0.1:2113/streams/SystemEvents/metadata {"$maxAge": 60}

It responds with The remote server returned an error: (400) Empty eventId provided…

-Svein Arne

You have to put an event type if just using the post. It’s $metadata I’ll push a change so if it’s not there is doesn’t care and just uses it. Use header Es-eventType

I am putting a patch into 3.0.1 for this right now. It will be allowed
as of this afternoon.

Cheers,

Greg

Nice! Putting in the header for now. Is there any way of creating an empty stream with the maxAge metadata or is an event required?

Post to metastream creates empty stream.

Here it replies with 404 when posting metadata to an unexisting stream.

Also posting to the metadata a second time responds with Created but metadata is unchanged. Is that intended?

Can you provide an example with curl?

Especially the second

Fuck I’m an idiot… my code tried to get the stream to pull the metadata url out… naturally it failed when no stream

Here is the curl stuff for non updating metadata

➜ ~ curl -i -d ‘{ “$maxAge”: 200 }’ “http://127.0.0.1:2113/streams/nonexistent/metadata” -H “Content-Type:application/json” -H “Es-eventType:maxage.warmup” -H “Es-eventId:fbf4a1a1-b4a3-4dfe-a01f-ec52c34e16e4”
HTTP/1.1 201 Created
Access-Control-Allow-Methods: GET, POST, GET, OPTIONS
Access-Control-Allow-Headers: Content-Type, X-Requested-With, X-PINGOTHER, Authorization, ES-LongPoll, ES-ExpectedVersion, ES-EventId, ES-EventType, ES-RequiresMaster, ES-HardDelete, ES-ResolveLinkTo, ES-ExpectedVersion
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Location, ES-Position
Location: http://127.0.0.1:2113/streams/%24%24nonexistent/0
Content-Type: text/plain; charset=utf-8
Server: Mono-HTTPAPI/1.0
Content-Length: 0
Keep-Alive: timeout=15,max=100

➜ ~ curl -i -d ‘{ “$maxAge”: 500 }’ “http://127.0.0.1:2113/streams/nonexistent/metadata” -H “Content-Type:application/json” -H “Es-eventType:maxage.warmup” -H “Es-eventId:fbf4a1a1-b4a3-4dfe-a01f-ec52c34e16e4”
HTTP/1.1 201 Created
Access-Control-Allow-Methods: GET, POST, GET, OPTIONS
Access-Control-Allow-Headers: Content-Type, X-Requested-With, X-PINGOTHER, Authorization, ES-LongPoll, ES-ExpectedVersion, ES-EventId, ES-EventType, ES-RequiresMaster, ES-HardDelete, ES-ResolveLinkTo, ES-ExpectedVersion
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Location, ES-Position
Location: http://127.0.0.1:2113/streams/%24%24nonexistent/0
Content-Type: text/plain; charset=utf-8
Server: Mono-HTTPAPI/1.0
Content-Length: 0
Keep-Alive: timeout=15,max=100

➜ ~ curl “http://127.0.0.1:2113/streams/nonexistent/metadata” -H “Accept:application/json”
{
“$maxAge”: 200
}% ➜ ~

You have to change the eventid or we will assume it’s idempotent. While it’s annoying with curl you will thank us in production :slight_smile:

Ok so setting metadata on the stream becomes an event internally in the eventstore?

Yes of course :slight_smile: and the eventid works the same as anywhere else. You wouldn’t want us to come up with a different way of working would you? :slight_smile:

Hehe :slight_smile: Does that mean that scavenge on maxAge is relative to the metadata event or does it impact the whole stream?

If you look metadata is in it’s own stream for /streams/foo it’s /streams/$$foo which is aliased as /streams/metadata.

As such maxage refers to the original stream and the metadata stream is separate

Cheers,

Greg

Ok get it. That means I get the expected behavior.

Thanks :slight_smile:

Btw never bookmark the $$stream we retain the right to change this at any point :slight_smile: always use the rel links if possible (or at least /metadata)

Nice to know. As of know I go through /streams/{stream_name} and parse the response to get the correct link for navigating and metadata. Unless the stream doesn’t exist. At that point I go directly on /metadata

Yeah there is no way of dealing with that without bookmarking (nor can
I come up with a good way of doing it).