I have a python code and using that python code i wanted to access: http://127.0.0.1:8080/alfresco/service/api/workflow-instances/
I am following one link https://docs.alfresco.com/5.2/concepts/dev-api-by-language-alf-rest-auth-with-repo.html where its mentioned that you need a ticket after that encode that ticket and use it to get the access.
Using the above link i am able to get Ticket and have encoded it but how i can use the ticket so that i can access that link using my python code.
Actually the url will give a json response and my requirement is to copy that json response and save it to my local system.
But while accessing the url http://127.0.0.1:8080/alfresco/service/api/workflow-instances/ its giving 401 Client Error: Unauthorized for url: http://127.0.0.1:8080/alfresco/service/api/workflow-instances/
Now i have the ticket so what changes i should do in the url or using the ticket so that i can get access to that page and save the json content .
Any kind of help will be appreciated.
Solved! Go to Solution.
Thanks @EddieMay for again giving quick response as expected from you always.
I resolved that issue by myself only .
I wrote a python code, earlier it was giving 401 Unauthorized file error .. but i used authentication while accessing the url and it works fine.
import requests
from requests.auth import HTTPBasicAuth
from urllib.error import HTTPError
try:
response = requests.get('http://your_host:8080/alfresco/service/api/workflow-instances?state=Completed', auth=HTTPBasicAuth('your_username', 'your_password'))
response.raise_for_status()
# access JSOn content
jsonResponse = response.json()
print("Entire JSON response")
print(jsonResponse)
except HTTPError as http_err:
print(f'HTTP error occurred: {http_err}')
Note:The code is compatible with python version >=3
Hi @akash251998
Have you had a chance to look at the API tutorial series? Also, have you tried using Postman for testing before attempting to implement with Python?
Also, have you looked at Alfresco API client libraries in Python?
HTH,
Thanks @EddieMay for again giving quick response as expected from you always.
I resolved that issue by myself only .
I wrote a python code, earlier it was giving 401 Unauthorized file error .. but i used authentication while accessing the url and it works fine.
import requests
from requests.auth import HTTPBasicAuth
from urllib.error import HTTPError
try:
response = requests.get('http://your_host:8080/alfresco/service/api/workflow-instances?state=Completed', auth=HTTPBasicAuth('your_username', 'your_password'))
response.raise_for_status()
# access JSOn content
jsonResponse = response.json()
print("Entire JSON response")
print(jsonResponse)
except HTTPError as http_err:
print(f'HTTP error occurred: {http_err}')
Note:The code is compatible with python version >=3
Hi @akash251998
Thanks for reporting back how you resolved your issue - that's really helpful to other users.
Kind regards,
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.