Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

 

This REST API sample will help you to understand how you can send events to BAM through the REST API. 

...

You need to have curl installed and available to the command line path. Curl can be downloaded from http://curl.haxx.se/download.html.

 

SAMPLE GUIDE 

 

Sample Guide

1. Start the WSO2 BAM Server.

...

5. Look at the rest-api.sh or rest-api.bat to take a look at the curl commands that are taking place.

Explanation of the HTTP

...

Requests

The body of the HTTP POST requests will be formed using the files in the same directory.

...

Code Block
curl -k --user admin:admin https://localhost:9443/datareceiver/1.0.0/streams/ --data @streamdefn1.json -H "Accept: application/json" -H "Content-type: application/json" -X POST

...

Listing 2 - Events for stream definition stockquote.stream, version 1.0.2  (events1.json)

...

Code Block
curl -k --user admin:admin https://localhost:9443/datareceiver/1.0.0/stream/stockquote.stream/1.0.2/ --data @events1.json -H "Accept: application/json" -H "Content-type: application/json" -X POST

...

Listing 3 - Stream definition - stockquote.stream.2, version 2.0.0 (streamdefn2.json)

...

  • Curl command for defining stream definition in listing 3.

 

Code Block
curl -k --user admin:admin https://localhost:9443/datareceiver/1.0.0/streams/ --data @streamdefn2.json -H "Accept: application/json" -H "Content-type: application/json" -X POST

 

Listing 4 - Events for Stream Definition, stockquote.stream.2, version 2.0.0 (events2.json)

Code Block
[
 {
   "payloadData" : ["IBM", 26.0, 848, 43.33, 2.3] ,
   "metaData" : ["123.233.0.1"] ,
   "correlationData" : ["2213-2324-2ffs-2444"],
   "timeStamp" : 1312345432
 },
 {
   "payloadData" : ["MSFT", 22.0, 233, 22.22, 4.3] ,
   "metaData" : ["5.211.1.1"],
   "correlationData" : ["1243-eeef-2969-3566"],
 }
]

 

  • Curl command for posting the two events in listing 4.
Code Block
curl -k --user admin:admin https://localhost:9443/datareceiver/1.0.0/stream/stockquote.stream.2/2.0.0 --data @events2.json -H "Accept: application/json" -H "Content-type: application/json" -X POST

 

...