- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2021 11:29 PM
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.
- Labels:
-
Alfresco Content Services
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2021 05:57 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2021 05:43 AM
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,
Problem solved? Click Accept as Solution!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2021 05:57 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2021 07:07 AM
Hi @akash251998
Thanks for reporting back how you resolved your issue - that's really helpful to other users.
Kind regards,
Problem solved? Click Accept as Solution!