Check response.
This commit is contained in:
parent
5db9681213
commit
7e370ae5f2
1 changed files with 8 additions and 2 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
@ -104,12 +105,17 @@ func (i *Dcim_Interfaces_Create) CreateInterface(n *NetBox) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data, err := ioutil.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return err
|
||||
}
|
||||
|
||||
if response.StatusCode == http.StatusCreated {
|
||||
fmt.Println(response.Body)
|
||||
fmt.Println(data)
|
||||
return nil
|
||||
} else {
|
||||
fmt.Println(response.Body)
|
||||
fmt.Println(data)
|
||||
return errors.Errorf("Response was: %d\n", response.StatusCode)
|
||||
}
|
||||
return nil
|
||||
|
|
Loading…
Reference in a new issue