Skip to content

ID is required to invoke public resource.Metadata$Service.getId() #53

@acamacho82

Description

@acamacho82

The Metadata service returns IllegalStateException error when calling to the methods getId(), getHostname(), etc.

java.lang.IllegalStateException: ID is required to invoke public abstract java.lang.Long com.softlayer.api.service.resource.Metadata$Service.getId()

Following code can be used to reproduce the issue.

public class TestMetadata {

    public static void main(String arg[]){
        String privateEndPoint = "https://api.service.softlayer.com/rest/v3/";
        ApiClient client = new RestApiClient(privateEndPoint);

        Metadata.Service metadataService = Metadata.service(client);

        try {            
            long id = metadataService.getId();            
            System.out.println("This VSI ID is " + id);            
        } catch (Exception e) {            
            System.out.println("SoftlayerMetadata error in " + e);
        }
    }
}

The problem is because the Metadata java class has set instanceRequired = true in all methods.

        @ApiMethod(instanceRequired = true)
        public Long getId();

Workaround
I created my own Metadata java class and I set instanceRequired = false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions