Check response.

This commit is contained in:
Kalle Carlbark 2019-09-11 09:43:40 +02:00
parent 5db9681213
commit 7e370ae5f2
No known key found for this signature in database
GPG key ID: 3FC0C93C5A5A0670

View file

@ -6,6 +6,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/pkg/errors" "github.com/pkg/errors"
"io/ioutil"
"net/http" "net/http"
"time" "time"
) )
@ -104,12 +105,17 @@ func (i *Dcim_Interfaces_Create) CreateInterface(n *NetBox) error {
if err != nil { if err != nil {
return err return err
} }
data, err := ioutil.ReadAll(response.Body)
if err != nil {
fmt.Println(err)
return err
}
if response.StatusCode == http.StatusCreated { if response.StatusCode == http.StatusCreated {
fmt.Println(response.Body) fmt.Println(data)
return nil return nil
} else { } else {
fmt.Println(response.Body) fmt.Println(data)
return errors.Errorf("Response was: %d\n", response.StatusCode) return errors.Errorf("Response was: %d\n", response.StatusCode)
} }
return nil return nil