netbox-community / go-netbox

The official Go API client for Netbox IPAM and DCIM service.
Other
195 stars 146 forks source link

Can't use with version v2.6.3 #71

Closed davidroman0O closed 3 years ago

davidroman0O commented 4 years ago

Hi,

I'm just trying to try the package but I got an issue when trying to get the list of racks:

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/netbox-community/go-netbox/netbox"
    "github.com/netbox-community/go-netbox/netbox/client/dcim"
)

func main() {
    c := netbox.NewNetboxWithAPIKey("localhost:6565", "mytokenwhatever")
    var limit int64 = 10
    var params dcim.DcimRacksListParams = dcim.DcimRacksListParams{
        Context: context.Background(),
        Limit:   &limit,
    }
    rs, err := c.Dcim.DcimRacksList(&params, nil)
    if err != nil {
        fmt.Printf("%v\n", err)
        os.Exit(1)
    }
    fmt.Printf("%v\n", *(rs.Payload.Count))
}

And I got :

json: cannot unmarshal number into Go struct field RackStatus.results.status.value of type string
exit status 1

The error is right, I tried to call the api with postman and I got :

"status": {
   "value": 0,
   "label": "Reserved"
},

But when looking at https://github.com/netbox-community/go-netbox/blob/master/netbox/models/rack.go, I see that RackStatus.value need a string.

I tried to use the latest and netbox_v2.6 versions of this package, same thing!

Any idea or a workaround for that?

Thx for your work 😄

TawR1024 commented 4 years ago

Have same problem. json: cannot unmarshal number into Go struct field VLANStatus.results.status.value of type string<nil>

netbox 2.6.6