Skip to content

Usage Documentation #19

Description

@ammopt

NGSI-Proxy Usage Documentation

  • Create eventsource:

    curl -X POST {{ngsiproxyurl}}/eventsource
    

    Sample create eventsource response:

    { 
     "connection_id":"353529a0-281a-11ec-b25b-6d62e91d5158",
     "url":"{{ngsiproxyurl}}/eventsource/353529a0-281a-11ec-b25b-6d62e91d5158"
    }
    
  • Create callback:

    Use the previously generated connection_id to create the
    callback:

    curl -X POST '{{ngsiproxyurl}}/callbacks' \
    --data-raw '{
                "connection_id": "353529a0-281a-11ec-b25b-6d62e91d5158"
    }'
    

    Sample create callback response:

    {
     "callback_id":"40b18800-281a-11ec-b25b-6d62e91d5158",
     "url":"{{ngsiproxyurl}}/callbacks/40b18800-281a-11ec-b25b-6d62e91d5158"
    }
    
  • Consume callback:

    The callback to be notified by the context-broker through a
    subscription. Use the previously generated callback_id to create
    the callback:

    curl -X POST '{{ngsiproxyurl}}/callbacks/40b18800-281a-11ec-b25b-6d62e91d5158' \
    --data-raw '{
     	    "keyofpayloadcontent": "valueofpayloadcontent"
    }'
    
  • Sample EventSource:

    Use the url returned in "Create eventsource"

    const sse = new EventSource('{{ngsiproxyurl}}/eventsource/353529a0-281a-11ec-b25b-6d62e91d5158');
    sse.addEventListener("notification", function(e) {
      console.log(JSON.parse(e.data));
    }) 
    

    This EventSource will fire everytime the callback is consumed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions