softlayer SDK SoftLayer_Exception_Public:访问被拒绝

Using examples in Go SDK with Username and apikey returned

{"error":"Access Denied. ","code":"SoftLayer_Exception_Public"}

package main

import (
    "fmt"

    "github.com/softlayer/softlayer-go/services"
    "github.com/softlayer/softlayer-go/session"
    "github.com/softlayer/softlayer-go/sl"
)

func main() {
        userName := "xxxx"
        apikey := "xxxx"
        sess := session.New(userName, apikey)
        sess.Debug = true
        doListAccountVMsTest(sess)
}

func doListAccountVMsTest(sess *session.Session) {
    service := services.GetAccountService(sess)

    vms, err := service.Mask("id;hostname;domain").Limit(10).GetVirtualGuests()
    if err != nil {
        fmt.Printf("Error retrieving Virtual Guests from Account: %s
", err)
        return
    } else {
        fmt.Println("VMs under Account:")
    }

    for _, vm := range vms {
        fmt.Printf("\t[%d]%s.%s
", *vm.Id, *vm.Hostname, *vm.Domain)
    }
}

func handleError(err error) {
    apiErr := err.(sl.Error)
    fmt.Printf(
        "Exception: %s
Message: %s
HTTP Status Code: %d
",
        apiErr.Exception,
        apiErr.Message,
        apiErr.StatusCode)
}

I didn't have issues when running your code, I recommend to check the username and apikey you are sending. See the API Access Information section in your profile https://control.softlayer.com/account/user/profile

It is worth noting that, it is not terribly well documented on IBM cloud, and the error messages returned are not terribly clear to this fact: Sometimes the Access Denied error you receive has more to do with the fact that you do not have an upgraded IBM pay as you go account.

Worth keeping that in mind, for other users that may run into the same error message, but not know what to make of it.