problem access REST API via Grail plugin rest-client-build

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2013 06:24 AM
I'm facing a problem call activiti REST API..
I'm calling REST API using grails plugin rest-client-build..
my code :
[
def index() {
def resp = rest.post('http://localhost:8080/activiti-rest/service/login') {
accept "application/json"
contentType "application/json"
json {
userId='kermit'
password='kermit'
}
}
println resp.status
}
def get() {
def resp = rest.get('http://localhost:8080/activiti-rest/service/process-instances') {
accept "application/json"
contentType "application/json"
}
println resp.status
}
]
when i called index().. it is success .. REST API response 200
but when i called get() .. it always returns 403
What should i do to correct that problem
thx
I'm calling REST API using grails plugin rest-client-build..
my code :
[
def index() {
def resp = rest.post('http://localhost:8080/activiti-rest/service/login') {
accept "application/json"
contentType "application/json"
json {
userId='kermit'
password='kermit'
}
}
println resp.status
}
def get() {
def resp = rest.get('http://localhost:8080/activiti-rest/service/process-instances') {
accept "application/json"
contentType "application/json"
}
println resp.status
}
]
when i called index().. it is success .. REST API response 200
but when i called get() .. it always returns 403
What should i do to correct that problem
thx
Labels:
- Labels:
-
Archive
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2013 11:11 AM
403 means you must be authenticated. The Activiti REST api uses BASIC auth, so you need to set the correct headers.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2013 01:00 AM
Hi Joram,
Thx for your info..
Now i'm successfully access the Activiti REST API..
this is my sample code in GRAILS using rest-client-builder plugin
[
def get() {
def resp = rest.get('http://localhost:8080/activiti-rest/service/user/kermit') {
auth "kermit","kermit"
accept "application/json"
contentType "application/json"
}
println resp.status
println resp.json.id
println resp.json.lastName
println resp.json
}
}
]
output :
200
kermit
The Frog
[id:kermit, lastName:The Frog, email:kermit@activiti.org, firstName:Kermit]
Thx for your info..
Now i'm successfully access the Activiti REST API..
this is my sample code in GRAILS using rest-client-builder plugin
[
def get() {
def resp = rest.get('http://localhost:8080/activiti-rest/service/user/kermit') {
auth "kermit","kermit"
accept "application/json"
contentType "application/json"
}
println resp.status
println resp.json.id
println resp.json.lastName
println resp.json
}
}
]
output :
200
kermit
The Frog
[id:kermit, lastName:The Frog, email:kermit@activiti.org, firstName:Kermit]
