cancel
Showing results for 
Search instead for 
Did you mean: 

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

suseno
Champ on-the-rise
Champ on-the-rise
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


2 REPLIES 2

jbarrez
Star Contributor
Star Contributor
403 means you must be authenticated. The Activiti REST api uses BASIC auth, so you need to set the correct headers.

suseno
Champ on-the-rise
Champ on-the-rise
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]