trouble with application/vnd.eventstore.events+json

Hi, sorry about this but I’m trying to get setup posting events from node.
I am using a curl client that is posting the following

curl --silent --show-error --no-buffer --url http://127.0.0.1:2113/streams/Command --data [{“eventId”:“6c869e00-5943-11e4-8489-0d41e862b024”,“ES-EventType”:“SomeEvent”,“data”:{“ProfileDetailsDto”:{“ProfileId":“475a8e64-6657-48ad-82bd-04c02c47a695”,“Email”:"[email protected]”,“Name”:“Raif the great”,“DisplayName”:“Raif the most exalted one”}},“metadata”:{“CommitId”:“6c86c510-5943-11e4-8489-0d41e862b024”,“CommandClrTypeName”:“ContactVendorForClientCmd”}}] --request POST --location --max-redirs 3 --header Accept: / --header Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 --header Accept-Language: en-US,en;q=0.8 --header Content-Type: application/vnd.eventstore.events+json --user-agent Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)

the code creating it looks like this

var myData = [

{

‘eventId’ : uuid.v1(),

‘ES-EventType’:‘SomeEvent’,

data:{

“ProfileDetailsDto”: {

“ProfileId”: “475a8e64-6657-48ad-82bd-04c02c47a695”,

“Email”: “[email protected]”,

“Name”: “Raif the great”,

“DisplayName”: “Raif the most exalted one”

}

},

“metadata”:

{

“CommitId”:uuid.v1(),

“CommandClrTypeName”:“ContactVendorForClientCmd”

}

}];

curl.request({url:‘http://127.0.0.1:2113/streams/Command’,

method:‘POST’,

headers:{‘Content-Type’:‘application/vnd.eventstore.events+json’},

data:JSON.stringify(myData)

// , pretend:true

},function(err, stdout, meta){

if(err){

console.log(err);

}else{

console.log(’%s %s’, meta.cmd, meta.args.join(’ '))

}

});

this results in not err value but also no post to the event store. However if I do the following

var myData =

{

data:{

“ProfileDetailsDto”: {

“ProfileId”: “475a8e64-6657-48ad-82bd-04c02c47a695”,

“Email”: “[email protected]”,

“Name”: “Raif the great”,

“DisplayName”: “Raif the most exalted one”

}

};

curl.request({url:‘http://127.0.0.1:2113/streams/Command’,

method:‘POST’,

headers:{ ‘eventId’ : uuid.v1(),

‘ES-EventType’:‘SomeEvent’,

‘Content-Type’:‘application/json’},

data:JSON.stringify(myData)

// , pretend:true

},function(err, stdout, meta){

if(err){

console.log(err);

}else{

console.log(’%s %s’, meta.cmd, meta.args.join(’ '))

}

});

this does post the event. again if I use this format with application/vnd.eventstore.events+json it does not.

the end goal is that I want event data and metadata and the former seems to be the way I’m supposed to do it.

If anyone can shed some light on this I would appreciate it.

Thanks,

R

In your first example why are you putting http headers in the data such ES-EventType

See eventstore media type here:

https://github.com/eventstore/eventstore/wiki/Writing-to-a-Stream-%28HTTP%29

Try

    var myData = [

        {

            'eventId' : uuid.v1(),

            'EventType' : "foo",

            data{

                "ProfileId": "475a8e64-6657-48ad-82bd-04c02c47a695",

                "Email": "[email protected]",

                "Name": "Raif the great",

                "DisplayName": "Raif the most exalted one"

        },

            "metadata":

        {

            "CommitId":uuid.v1(),

            "CommandClrTypeName":"ContactVendorForClientCmd"

        }

        }]

Just did quickly on iPad so may be errors but should get the idea

Right, thanks man,
basically I looked at the single message docs and it had eventId and ES_EventType header values, then in the multi message docs those headers were not there, but the json had eventId, eventType, so assumed that data should be moved, but did not notice the difference.
Anyway, thanks a lot.

Raif

P.s.

I’d love to see a unit test for:

"this results in not err value but also no post to the event store. "

As I am looking at the line of code that errors without an event type set. https://github.com/EventStore/EventStore/blob/dev/src/EventStore.Core/Services/Transport/Http/Controllers/AtomController.cs#L150

I would revisit how you handle errors :slight_smile:

Greg

Raif,

In my ges-client repo I have (highly untested, but was working in the 3.0RC range) an http transport from node if you’d like to take a peek. https://github.com/bmavity/ges-client/blob/master/http/makeRequest.js

Well, call me unrefined, but this stuff is so fresh for me that I’m not doing unit tests. It’s in constant massive upheaval. When I have a structure and infrastructure I will start to write unit tests. The lack of err comes from caveman debugging through the console. console.log(err) == undefined.
It does seem that if I had received the error message, I would have been able to spare you your time. A unit test would have been more likely to reveal that. Not sure why it came through as undefined, but I can be pretty sure I’m doing something wrong. Anyway, works now, thank you for the help.
@brian I will definitely take a look, thanks for the link.