package main import fmt io ioutil log net http func main client http C

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
func main() {
client := &http.Client{}
var data = []byte(`{@fixlet.xml}`)
req, err := http.NewRequest("POST", "https://server:port/api/fixlets/operator/bigfix", data)
if err != nil {
log.Fatal(err)
}
req.SetBasicAuth("username", "password")
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
bodyText, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", bodyText)
}