0

In Datahug's documentation, it states, 'Authentication is performed using HTTP Basic Authentication - A Datahug username and password will be required in order to access the API.'

As a result, I've tried the below (with my username and password defined)

import requests
from requests.auth import HTTPBasicAuth

url = 'https://api.datahug.com/Contact/'
l = requests.get(url,auth=HTTPBasicAuth(username,password)

But I receive the following error:

<Response [401]>

Am I doing something wrong here?

I've also tried the following:

import requests
from requests.auth import HTTPBasicAuth

url = "https://api.datahug.com/Contact/test@test.com"
l = requests.get(url,auth=(username,password))
Chris
  • 5,444
  • 16
  • 63
  • 119
  • Not the problem, but you don't need to create a `HTTPBasicAuth()`, you can just pass the tuple `auth=(username, password)`. – mhawke Feb 18 '16 at 23:02
  • Is that the actual URL that you are using (it 404s for me)? According to the documentation you need to append the contact to the url, e.g. `https://api.datahug.com/Contact/test@test.com`. So the next obvious thing to check is that your credentials are correct, and whether the contact you are requesting exists. Otherwise I don't see that you are doing anything wrong. Maybe you should contact their [support](https://api.datahug.com/#support) – mhawke Feb 18 '16 at 23:12
  • Thanks - I've tried your solutions and updated question. I've sent this stackoverflow question to them so I'm hoping they can answer. – Chris Feb 18 '16 at 23:22
  • Do you have a real contact for which you are authorised? `test@test.com` is merely an example, I assume that you are using a genuine contact. – mhawke Feb 18 '16 at 23:27

1 Answers1

1

I've tracked the issue down to the Datahug Edition your account was configured to. It was CRM Only which at the moment doesn't allow API access. I've changed the account Edition to Full which will also give you access to the web app and you will also be able to make api calls.

You should now get a valid response when you make API calls.

Kevin Brady
  • 1,684
  • 17
  • 30