'No such field found: field java.lang.String sinput error while running my jenkinsfile

Getting No such field found: field java.lang.String sinput error while running my Jenkinsfile.

I have developed a Jenkinsfile that would take a user input and further would run a command on remote machine taking the user input as a variable

stages {
    stage("Interactive_Input") {
        steps {
            script {
                def apiinput
                def userInput = input(
                        id: 'userInput', message: 'This is my project',
                        parameters: [
                                string(defaultValue: 'None',
                                        description: 'Enter the name of the service',
                                        name: 'sinput'),
                                
                        ])
                // Save to variables. Default to empty string if not found.
                apiinput = userInput.sinput?:''
            }
        }
    }
}


Solution 1:[1]

well ... I had such an issue and in my case it was the way I was using variables When I did like $VARIABLE it wasn't working and I had an error like the one described here. However when I did ${VARIABLE} -> it has all worked!!!

Solution 2:[2]

For me the issue was trying to access length as an attribute instead of length() as a method. Basically missing parenthesis.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ????? ???
Solution 2 barakbd