Salta ai contenuti

Connettore HTTP/REST

Il connettore HTTP abilita la comunicazione con API REST e servizi web.

Tipi Connettore:

  • HttpReader - Polling endpoint HTTP (richieste GET)
  • HttpWriter - Invia dati a endpoint HTTP (POST, PUT, DELETE)

Polling periodico di un endpoint HTTP:

{
"type": "HttpReader",
"config": {
"endpoint": "http://api.example.com/data",
"pollingRate": 5000,
"method": "GET",
"headers": {
"Authorization": "Bearer YOUR_TOKEN",
"Accept": "application/json"
}
}
}

Invia dati via POST:

{
"type": "HttpWriter",
"config": {
"endpoint": "http://api.example.com/data",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_TOKEN"
}
}
}

Aggiorna dati via PUT:

{
"type": "HttpWriter",
"config": {
"endpoint": "http://api.example.com/data/123",
"method": "PUT",
"headers": {
"Content-Type": "application/json"
}
}
}
  • endpoint: URL completo incluso protocollo
  • method: Metodo HTTP (GET, POST, PUT, DELETE)
  • pollingRate: (Solo Reader) Intervallo polling in millisecondi
  • headers: Header HTTP personalizzati (oggetto)
  • timeout: (Opzionale) Timeout richiesta in millisecondi
{
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer token",
"Accept": "application/json",
"User-Agent": "Meddle/1.0"
}
}
{
"type": "HttpReader",
"config": {
"endpoint": "https://api.weather.com/v1/current?location=factory",
"pollingRate": 300000,
"method": "GET",
"headers": {
"API-Key": "your-api-key"
}
}
}
{
"type": "HttpWriter",
"config": {
"endpoint": "https://hooks.example.com/webhook",
"method": "POST",
"headers": {
"Content-Type": "application/json"
}
}
}
  • MQTT - Alternativa messaggistica IoT
  • Reshape - Trasforma risposte HTTP