Problem:
When calling GET https://api.softlayer.com/rest/v3/SoftLayer_Product_Package/257/getConfiguration?objectMask=mask[itemCategory], the ItemCategory object is populated in REST, but not in Golang, despite declaring it in the mask.
import ( "github.com/softlayer/softlayer-go/services" ) // ... // Object-Mask to get specific Vlan's information mask := "itemCategory" // Call to getNetworkVlans in order to retrieve vlans according to filter. result, err := service.Mask(mask).Id(257).GetConfiguration() if err != nil { fmt.Printf("\n Unable to retrieve config:\n - %s\n", err) return }
Sample output:
{ "id": 7167, "isRequired": 0, "itemCategoryId": 390, "orderStepId": 1, "packageId": 257, "sort": 0 }
Solution:
The issue arises because the default endpoint for the SoftLayer API in Go is XMLRPC, which does not support retrieving the ItemCategory object. To rectify this, switch to the REST endpoint by updating the session configuration:
endpoint := "https://api.softlayer.com/rest/v3" // Create a session sess := session.New(username, apikey, endpoint)
This should populate the ItemCategory object in the API response as expected.
The above is the detailed content of Why is the ItemCategory object not populated in Golang\'s GetConfiguration call despite being declared in the mask?. For more information, please follow other related articles on the PHP Chinese website!