yosri slama yosri slama - 1 year ago 131
Python Question

how can i update an alfresco share site?

I am trying to update a website (just change its name) I have created with the Share script in Alfresco, but I am getting a

response. I'm sure my login and password are correct.


s = requests.Session()
data = {'username':"admin", 'password':"admin"}
url = ""
r = s.post(url, data=data)
if (r.status_code != 200) :
print "Incorrect login or password "
url1 = ""
print url_alfresco

jsonString = JSONEncoder().encode({
"title" : name

headers = {'content-type': 'application/json',"Accept":"application/json"}
site = s.put(url1,headers=headers,data=data)

if (site.status_code != 200) :
print " Error while creating site"
print site.status_code

I am getting the error on the second part. The login part works without any problems.
Can you tell me what I do wrong?

Answer Source

This is because you are using different contexts to make your queries.

The Alfresco stack is made of multiples parts :

  • alfresco.war
  • share.war
  • solr.war

If we forget the solr part and focus on your problem, you have :

  • a content repository (alfresco) which contains the core services of alfresco
  • a web application (share) which contains the web ui of your application and communicate the content repository to do some actions

They don't share the same context and have different lives. One can be on a server, the other one can be in another one server.

So this mean, when you are authenticating, you are doing it on the share context :

and when you are trying to update your website, you are doing it on the alfresco context (on which you are not authenticated yet) :

I see two solutions then :

  1. You do your authentication on the alfresco context (webservice alfresco/s/api/login) and then you will be authenticated for calling your alfresco site services
  2. You pass through the share proxy : /alfresco/service/api/sites becomes /alfresco/service/api/sites
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download