GO - Create Monitor Group in Site24x7 via REST API + JSON

package main

import (
"bytes"
    "fmt"
    "net/http"
    "io/ioutil"
)

func main() {
    url := "https://www.site24x7.com/api/monitor_groups"
    fmt.Println("URL:>", url)

    var jsonStr = []byte(`
{
   "display_name": "Test Automation Group",
    "description": "Include Test Automation Monitors In This Group"
}`)


    req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
req.Header.Set("Authorization", "Zoho-authtoken <replace with your token-id>")
req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    fmt.Println("response Status:", resp.Status)
    fmt.Println("response Headers:", resp.Header)
    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println("response Body:", string(body))

}

Comments

Popular posts from this blog

Basic Send Message to MQ with Java and IBM MQ JMS

Basic Receive Message to MQ with Java and IBM MQ JMS

Configure Database Connection using MyBatis