Im trying to access CommCare API but i keep getting 401 Unauthorized and im using this simple python script just for testing.
from requests.auth import HTTPDigestAuth
url = ‘https://www.commcarehq.org/a/demo-218/api/v0.5/form/’
r = requests.get(url, auth=HTTPDigestAuth(‘user’, ‘pass’))
I should be able to get status code 201. Im using the correct user and pass but still 401?
Do i have to have atleast standard subscription to access the API?
Hi, yes, API access is limited to Standard plans or above.
If you print the body of the response there should be more detail about the problem. In this case, it should notify you that the subscription doesn’t have access to this feature.
@Ethan_Soergel I tried to print the content and it says ‘Authorization Required’.
And when i look on what subscription plan i have it looks like this:
The 30 Day Trial includes all the features present in the CommCare Advanced Trial Software Plan, which is our full set of features.
So that should mean that i can access the API?
That’s correct, you should be able to access the API. I just tested it out myself and was able to access the API on a trial project space using the same code you provided above.
You should use the same username and password you use to log in to CommCareHQ. Does your user have two-factor authentication enabled? If so, I think you’ll need to use an API key instead.