Table of Contents | ||||
---|---|---|---|---|
|
...
Element | Description |
---|---|
| Use the endpoint that corresponds to the Devo Cloud region you use. |
| This can be one of the following:
|
| The name of the Devo domain where the events are being sent to. |
| The token you generated in Devo to authorize your connection. |
| Specify the required hostname. |
| The Devo tag to be applied to the events. Learn more about tags in About Devo tags. |
| The log to be sent. Note that this is only valid if you’re using the In case of a |
Here is an example of an endpoint URL:
Code Block |
---|
https://http-us.devo.io/event/myDomain/token!a5370g9e8f7d7edf9d/local1/my.app.http.js?this%20is%20a%20example%20of%20log |
...
Rw ui tabs macro | ||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Send a single event in a single HTTP request using the URL query string to encode the event message. This method uses the HTTP GET method. Anatomy of the request
Examples Rw expand | | title |
Code Block |
---|
const https = require('https'); const URL_HOST = process.env.URL_HOST; const URL_PORT = process.env.URL_PORT || 443; const TOKEN = process.env.TOKEN; const DOMAIN = process.env.DOMAIN; const HOST = process.env.HOST; const TAG = process.env.TAG; const ACCEPT_UNAUTHORIZED = process.env.ACCEPT_UNAUTHORIZED !== undefined; const message = 'This is Sparta!'; const querystring = encodeURIComponent(message); const options = { hostname: URL_HOST, port: URL_PORT, path: `/event/${DOMAIN}/token!${TOKEN}/${HOST}/${TAG}?${querystring}`, method: 'GET', headers: { 'Content-Type': 'text/plain', }, rejectUnauthorized: !ACCEPT_UNAUTHORIZED }; const req = https.request(options, res => { console.log(`statusCode: ${res.statusCode}`); res.on('data', chunk => console.log(`Response: ${chunk}`)); }); req.on('error', err => console.error(err)); req.end(); |
Python
Code Block |
---|
import http.client import ssl import os import urllib URL_HOST = os.environ.get("URL_HOST") URL_PORT = os.environ.get("URL_PORT", 443) TOKEN = os.environ.get("TOKEN") DOMAIN = os.environ.get("DOMAIN") HOST = os.environ.get("HOST") TAG = os.environ.get("TAG") ACCEPT_UNAUTHORIZED = os.environ.get("ACCEPT_UNAUTHORIZED") context = ( ssl._create_unverified_context() if ACCEPT_UNAUTHORIZED else ssl.create_default_context() ) conn = http.client.HTTPSConnection(URL_HOST, URL_PORT, context=context) message = urllib.parse.quote("This is Sparta!") path = f"/event/{DOMAIN}/token!{TOKEN}/{HOST}/{TAG}?{message}" headers = {"Content-Type": "text/plain"} conn.request("GET", path, headers=headers) response = conn.getresponse() print(response.status) print(response.read().decode()) conn.close() |
Bash
Code Block |
---|
#!/usr/bin/env bash if [[ -z "$URL_HOST" || -z "$TOKEN" || -z "$DOMAIN" || -z "$HOST" || -z "$TAG" ]]; then echo "Please set all required environment variables: URL_HOST, TOKEN, DOMAIN, HOST, TAG" exit 1 fi URL_PORT="${URL_PORT:-443}" MESSAGE="This is Sparta!" URL="https://$URL_HOST:$URL_PORT/event/$DOMAIN/token!$TOKEN/$HOST/$TAG" curl -v -G --data-urlencode "$MESSAGE" "$URL" |
Rw tab | ||
---|---|---|
|
Send a single event in a single HTTP request using the body to encode the event message. This method uses the HTTP POST method.
Anatomy of the request
Code Block |
---|
POST <endpoint>/event/<domain>/token!<token>/<host>/<tag> HTTP/1.1 Host: <host> Content-Length: <message length> <message> |
Examples
Rw expand | ||
---|---|---|
|
Code Block |
---|
const https = require('https'); const URL_HOST = process.env.URL_HOST; const URL_PORT = process.env.URL_PORT || 443; const TOKEN = process.env.TOKEN; const DOMAIN = process.env.DOMAIN; const HOST = process.env.HOST; const TAG = process.env.TAG; const ACCEPT_UNAUTHORIZED = process.env.ACCEPT_UNAUTHORIZED !== undefined; const options = { hostname: URL_HOST, port: URL_PORT, path: `/event/${DOMAIN}/token!${TOKEN}/${HOST}/${TAG}`, method: 'POST', headers: { 'Content-Type': 'text/plain', }, rejectUnauthorized: !ACCEPT_UNAUTHORIZED }; const req = https.request(options, res => { console.log(`statusCode: ${res.statusCode}`); res.on('data', chunk => console.log(`Response: ${chunk}`)); }); req.on('error', err => console.error(err)); const message = 'This is Sparta!'; req.end(message); |
Rw expand | ||
---|---|---|
|
Code Block |
---|
import http.client import ssl import os URL_HOST = os.environ.get("URL_HOST") URL_PORT = os.environ.get("URL_PORT", 443) TOKEN = os.environ.get("TOKEN") DOMAIN = os.environ.get("DOMAIN") HOST = os.environ.get("HOST") TAG = os.environ.get("TAG") ACCEPT_UNAUTHORIZED = os.environ.get("ACCEPT_UNAUTHORIZED") context = ( ssl._create_unverified_context() if ACCEPT_UNAUTHORIZED else ssl.create_default_context() ) conn = http.client.HTTPSConnection(URL_HOST, URL_PORT, context=context) path = f"/event/{DOMAIN}/token!{TOKEN}/{HOST}/{TAG}" headers = {"Content-Type": "text/plain"} body = "This is Sparta!".encode("utf-8") conn.request("POST", path, body=body, headers=headers) response = conn.getresponse() print(response.status) print(response.read().decode()) conn.close() |
Rw expand | ||
---|---|---|
|
Code Block |
---|
#!/usr/bin/env bash if [[ -z "$URL_HOST" || -z "$TOKEN" || -z "$DOMAIN" || -z "$HOST" || -z "$TAG" ]]; then echo "Please set all required environment variables: URL_HOST, TOKEN, DOMAIN, HOST, TAG" exit 1 fi URL_PORT="${URL_PORT:-443}" MESSAGE="This is Sparta!" URL="https://$URL_HOST:$URL_PORT/event/$DOMAIN/token!$TOKEN/$HOST/$TAG" curl -v --data "$MESSAGE" "$URL" |
...