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"
|
"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
|
||||||
|
|
Loading…
Reference in a new issue