Go

ThingsOn HTTP API / Go

Go programlama dilini kullanarak platforma veri göndermek için aşağıdaki örneği kullanabilirsiniz.

Write
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "http://cloud.thingson.io:8086/write?db=[DB_NAME]"
payload := strings.NewReader("[TABLE_NAME] [FIELD_1=90],[FIELD_2=90],[FIELD_3=90]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic [API_KEY]")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}