.Maui Blog

Go HTTP POST request

With today’s post we return to regularly post on our blog.
The first series of posts will be dedicated to the Go programming language. It is a language we highly appreciate and we used it to create our dashboard.

In this example we show how to perform a request in Go with the POST method to our API.

package main

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

func main() {
	
  endpoint := "https://api.dotmaui.com/client/1.1/vulturecss/"
	
  resp, err := http.PostForm(endpoint,
     url.Values{"apikey": {"YOUR_API_KEY"}, "css": {".maui{color:#FFFFFF;}"}})

  defer resp.Body.Close()
    body, err := ioutil.ReadAll(resp.Body)
	
    if err != nil {
      panic(err)
    }
    
  fmt.Println(string(body))
	
}
Exit mobile version