cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Credential to Share REST API

ddelapasse
Champ in-the-making
Champ in-the-making
From my web app I would like to request the Share metadata edit form and grab the fields/controlTypes to pass over to my Web UI.  I realize there are CMIS/Alfresco apis to get the metadata, but we define aspects that reuse properties of existing content model attributes and only share (share-custom-config.xml) has the knowledge for the exact view/edit configurations.

So…I found that I can call the api if I am logged in, but no combination of ticket=, alf_ticket=, u= pw= …is allowing me to hit the url programmatically. Is there any way to do this?

I just want to pass it my app's credentials so the user doesn't have to manually login to ALfresco!
This is the specific URL I want to hit:

http://localhost:8080/share/service/components/form?itemKind=node&itemId={nodeRefId}&mode=edit&submi...}

2 REPLIES 2

arak
Confirmed Champ
Confirmed Champ
Hi,

You can use the API RESTful of Alfresco (webscripts of the repository layer).

Specifically, for the login, in your custom web application, you can use:

URL: http://IP:PORT/alfresco/service/api/loginMethod: POSTRequest Body: {username:"your-user",password:"your-password"}Response: The ticket of your login (i.e.: TICKET_0524c0877175d3da841b0c6c48822e2ae3516824).‍‍‍‍‍‍


And for the logout:

URL: http://IP:PORT/alfresco/service/api/login/ticket/TICKET?alf_ticket=TICKETMethod: DELETERequest Body: nothingResponse: an XML response with code 200‍‍‍‍‍‍


If you need get the metadata of a specific content (I suspect you know the node reference), you can use:

URL: http://IP:PORT/alfresco/service/api/node/content/workspace/SpacesStore/NODEREF?alf_ticket=TICKETMethod: GETRequest Body: nothingResponse: An XML with the data of the content‍‍‍‍‍‍


For edit the metadata, you can use:

URL: http://IP:PORT/alfresco/service/api/metadata/node/workspace/SpaceStore/NODEREF?alf_ticket=TICKETMethod: POSTRequest Body (i.e): {properties:{cm:title:"your title",cm:description:"your description"}}Response: 200‍‍‍‍‍‍


But, I read which the experts recommend the use of CMIS for edit properties, aspects and the content in general. More information in: http://stackoverflow.com/questions/28804597/set-apects-via-rest-api-call-in-alfresco

I hope this help.

Greetings,
Pablo V.

ddelapasse
Champ in-the-making
Champ in-the-making
Pablo, Thanks for the nice reply, but I need to use the Share api and NOT the repo api. Your answer is definitely true for repo, but it seems that the Share api requires a different type of authentication.  When called from a browser I can make it work passing over the CRSFilter token and some other attributes, but hoping there's a simpler way to accomplish this from a Java application.  I don't need the ftl page to actually DRAW, I just want to get the html back and parse out what I need.

Thanks again for trying to help!