cancel
Showing results for 
Search instead for 
Did you mean: 

Call a webscript within an Evaluator

drocco88
Champ in-the-making
Champ in-the-making
Hi all,

I need to call a custom web script from my evaluator (java).

I'm having some problems with authentication (calling a URL directly from Java). I tried with /alfresco/service, /alfresco/wcservice and /share/proxy/alfresco.

Have someone done this before or have an idea on how to do it?

Many thanks
R
15 REPLIES 15

drocco88
Champ in-the-making
Champ in-the-making
Sorry my bad was working from within the browser but not from java. I will try give me a couple of minutes.

Thanks 🙂

drocco88
Champ in-the-making
Champ in-the-making
I got it working now 🙂

using your snippet the first time I didn't realize that the url as parameter for connector.call(url) has to be only "/api/people/…"

Thanks very much for your help Dave

drocco88
Champ in-the-making
Champ in-the-making
Sorry a last quick question:

The response returns a String, is there a way to handle the response as a JSON object?

ddraper
World-Class Innovator
World-Class Innovator
(Assuming you're using the WebScript I recommended) Try this:

org.json.simple.parser.JSONParser p = new org.json.simple.parser.JSONParser();
Object o = p.parse(response);
if (o instanceof org.json.simple.JSONObject)
{
    org.json.simple.JSONObject jsonRes = (org.json.simple.JSONObject) o;
    org.json.simple.JSONArray groupsList groupsList = (org.json.simple.JSONArray) jsonRes.get("groups");
    Iterator i = groupsList.iterator();
    while (i.hasNext())
    {                           
        org.json.simple.JSONObject group = (org.json.simple.JSONObject) i.next();
        String currGroupName = group.get("itemName").toString();
    }
}

drocco88
Champ in-the-making
Champ in-the-making
Awesome!

sorry if this was obvious but I recently started with Alfresco.

Hopefully in a couple of weeks it will be better.

Cheers

ddraper
World-Class Innovator
World-Class Innovator
No problem… happy to help. At least you've found out what an awesome community Alfresco has Smiley Happy