Skip to content

[Question] Print price list ID is required #22

@critix

Description

@critix

I want to print a list of prices to get the right ID to create a subnet. I tried to look for a way to give my account ID through the ApiClient but this didn't need the ID. When I run the code it give me following error:
Exception in thread "main" java.lang.IllegalStateException: ID is required to invoke public abstract java.util.List com.softlayer.api.service.product.item.Price$Service.getPackageReferences()
at com.softlayer.api.RestApiClient$ServiceProxy.invokeService(RestApiClient.java:282)
at com.softlayer.api.RestApiClient$ServiceProxy.invoke(RestApiClient.java:466)
at com.sun.proxy.$Proxy8.getPackageReferences(Unknown Source)
at applicatie.getPrices(applicatie.java:430)
at applicatie.main(applicatie.java:78)

This is the code I use:

ApiClient client = new RestApiClient()
.withCredentials("OUR USERNAME",
"THE KEY");
getPrices(client,account);

public static void getPrices(ApiClient client, Account account) {
    Price.Service servicePrices = Price.service(client);

    List<Prices> p = servicePrices.getPackageReferences();

    for (Prices price : p) {
        System.out.println(price.getId() + price.getItemPriceId());
    }
}

Does anyone have the code to print a list of ID's and Names to find the subnet priceId. Or does someone have the code to create one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions