Skip to content

Instantly share code, notes, and snippets.

@kastork
Created March 8, 2013 17:44
Show Gist options
  • Save kastork/5118301 to your computer and use it in GitHub Desktop.
Save kastork/5118301 to your computer and use it in GitHub Desktop.
Add a Liferay user via JSON Web Service
@Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='0.7.2')
import wslite.rest.*
import wslite.http.auth.*
println "This is the add user script"
def client = new RESTClient("http://localhost:8080/api/jsonws/")
client.authorization = new HTTPBasicAuthorization("test@liferay.com", "test")
client.httpClient.sslTrustAllCerts = true
def myQuery = [
companyId: '10154',
autoPassword:'true',
password1:'',
password2:'',
autoScreenName:'true',
screenName:'',
emailAddress:'testy@example.com',
facebookId:'0',
openId:'',
locale:'en',
firstName:'Testy',
middleName:'the',
lastName:'Tester',
prefixId:'0',
suffixId:'0',
male:'true',
birthdayMonth:'0',
birthdayDay:'1',
birthdayYear:'1970',
jobTitle:'',
groupIds:'',
organizationIds:'',
roleIds:'',
userGroupIds:'',
sendEmail:'false'
]
println ""
def response = client.post( path:'user/add-user') {
urlenc myQuery
}
println ""
println response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment