Why is the ItemCategory object not populated in Golang\'s GetConfiguration call despite being declared in the mask?

Susan Sarandon
Release: 2024-11-22 14:16:48
Original
876 people have browsed it

Why is the ItemCategory object not populated in Golang's GetConfiguration call despite being declared in the mask?

Unable to Get ItemCategory Info from GetConfiguration Call in Golang

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
}
Copy after login

Sample output:

{
    "id": 7167,
    "isRequired": 0,
    "itemCategoryId": 390,
    "orderStepId": 1,
    "packageId": 257,
    "sort": 0
}
Copy after login

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)
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template