bluemix-go icon indicating copy to clipboard operation
bluemix-go copied to clipboard

Bug: accountv2Client.List() always throws Error: Request failed with status code: 500, internal_error

Open ParthaI opened this issue 11 months ago • 1 comments

Hello Team,

I'm attempting to retrieve a list of all accounts on my IBM Cloud using the List() API call from the accountv2 package. Unfortunately, I keep encountering the following error: Error: Request failed with status code: 500, internal_error.

Below is the source code I've been working with:

package main

import (
	"fmt"

	"github.com/IBM-Cloud/bluemix-go"
	"github.com/IBM-Cloud/bluemix-go/api/account/accountv2"
	"github.com/IBM-Cloud/bluemix-go/session"
)

func main() {
	conf := &bluemix.Config{
		BluemixAPIKey: "YOUR_IBMCLOUD_API_KEY",
	}

	s, err := session.New(conf)
	if err != nil {
		panic("Error in session creation: " + err.Error())
	}

	svc, err := accountv2.New(s)
	if err != nil {
		panic("Error in Account client: " + err.Error())
	}
	client := svc.Accounts()
	res, err := client.List()

	if err != nil {
		panic("Error in Account List API call: " + err.Error())
	}

	for _, acc := range res {
		fmt.Printf("Account Name: %s", acc.Name)
	}

}

If there are any corrections needed or best practices I might have overlooked, I'd greatly appreciate your guidance. This issue is currently a significant obstacle in our project's progress, so any expedited advice or solutions would be immensely valuable.

Thank you for your support!

ParthaI avatar Mar 08 '24 07:03 ParthaI

The above is based on CF (MCCP) endpoint which is deprecated and stopped the service.

Added support to retrive accoutns without CF https://github.com/IBM-Cloud/bluemix-go/pull/433

hkantare avatar Mar 08 '24 14:03 hkantare