## Publish

- API to publish events to Avaya Breeze.

- - ###

    Method | POST
    URL | /services/EventingConnector/events
    Content-type | multipart/form-data, application/json
    Response | A success response is a simple 200 OK

- - #### Request Content-type as multipart/form-data

    Names of the various form fields are -
    - Event parameters -family, type and version are the mandatory parametes to publish an event.
    - Event Metadata parameters - metadata-user, metadata-correlationId
      Any other metadata key-value pairs needs to be set as separate form fields, such as metadata-key1, metadata-key4, etc.
    - Event Body - eventBody

    Sample request using chrome postman

    Sample code snippet in cURL

        curl -X POST \
        	http://example.com/services/EventingConnector/events \
        	-H 'content-type: multipart/form-data' \
        	-F family=f1 \
        	-F metadata-user=u131 \
        	-F eventBody=@san1.csv \
        	-F type=Type3 \
        	-F version=2.0 \
        	-F metadata-producerName=mytester \
        	-F metadata-producerVersion=3.5

    Sample code snippet in javascript jQuery AJAX

        var form = new FormData();
        form.append("family", "f1");
        form.append("metadata-user", "u131");
        form.append("type", "Type3");
        form.append("version", "2.0");
        form.append("metadata-producerName", "myapp");
        form.append("metadata-producerVersion", "3.5");

        var settings = {
          "async": true,
          "crossDomain": true,
          "url": "http://example.com/services/EventingConnector/events",
          "method": "POST",
          "processData": false,
          "contentType": false,
          "mimeType": "multipart/form-data",
          "data": form
        }

        $.ajax(settings).done(function (response) {
          console.log(response);
        });

  - #### Request Content-type as application/json

    Names of the various properties are -
    - Event parameters -family, type and version are mandatory to publish an event.
    - Event Metadata parameters - user, correlationId
      Any other metadata key-value pairs are set as additional properties
    - Event Body - eventBody
    this is a free form json

    Sample request using chrome postman

    Sample code snippet in python

        import http.client

        conn = http.client.HTTPConnection("example.com")

        payload = "{\"family\" : \"f1\",\"type\" : \"t2\",\"version\" : \"1.0\",\"eventMetaData\" : {\"user\" : \"u131\",\"additionalProperties\" : {\"k1\" : \"v1\",\"k2\" : \"v2\"}},\"eventBody\" : {\"a\" : \"a1\",\"b\" : \"b1\",\"ar1\" : {\"abcd\" : \"pqrs\",\"xyz\" : \"123\",\"iar1\" : {\"x1\" : \"y1\",\"x2\" : \"y2\"}}}}"

        headers = {
            'content-type': "application/json"
            }

        conn.request("POST", "/services/EventingConnector/events", payload, headers)

        res = conn.getresponse()
        data = res.read()

        print(data.decode("utf-8"))

    Sample code snippet in cURL

        curl -X POST \
          http://example.com/services/EventingConnector/events \
          -H 'content-type: application/json' \
          -d '{
        	"family" : "f1",
        	"type" : "t2",
        	"version" : "1.0",
        	"eventMetaData" : {
        		"user" : "u131",
        		"additionalProperties" : {
        			"k1" : "v1",
        			"k2" : "v2"
        		},
        		"producerVersion": "1.0",
        		"producerName": "MyApp"
        	},
        	"eventBody" : {
        		"a" : "a1",
        		"b" : "b1",
        		"ar1" : {
        			"abcd" : "pqrs",
        			"xyz" : "123",
        			"iar1" : {
        				"x1" : "y1",
        				"x2" : "y2"
        			}
        		}
        	}
        }'

Copyright © 2017 Avaya. All Rights Reserved.