getLabelString is erroring out with a datatype error

getLabelString is erroring out with a datatype error.
Whenever I try to run the following command:
def list_labels = objnode.getLabelString().split(’ ') as List
from within my groovy script it errors out with the following error:

groovy.lang.MissingMethodException: No signature of method: hudson.model.Hudson$MasterComputer.getLabelString() is applicable for argument types: () values:

what is wrong here?

To obtain your Jenkins version and an exhaustive list of plugins and their versions, paste the code snippet located at Issue Reporting into your script console, and post the output below under “Jenkins setup”:

Jenkins setup:

Seems you’re calling getLabelString on an instance of the Computer class. But there is no such method there.

getLabelString is defined on the Node class.
If my assumption is correct then objnode.getNode().getLabelString() should do the trick

okay great! that worked and what about setLabelString ?

See Node (Jenkins core 2.450 API)

Isn’t getLabelString() a function that should give you all the labels corresponding to a particular node in jenkins and setLabelString() is something to set more labels to the node. Somehow whenever I use getLabelString on a particular node it does not yield any of the labels that a node currently has. Is there something that I am doing wrong here?

what is the node name and which labels did you assign to the node?