0
import requests

url = 'https://api.assembla.com/v1/spaces'
API_KEY = "API_KEY"
API_SECRET = "API_SECRET "
resp = requests.get(url, auth=(API_KEY, API_SECRET))
print(resp.status_code)

I keep getting 401. I'm not sure how to use an API_KEY and an API_SECRET to download a pdf file (let's call it test.pdf) from an assembla url given to me. Any help appreciated.

RiptimRip
  • 11
  • 1
  • 3

1 Answers1

0

Does seem like you need to use those as headers instead based from their documentation

import requests

url = 'https://api.assembla.com/v1/spaces'

headers = {
    "X-Api-Key": "API_KEY",
    "X-Api-Secret": "API_SECRET"
}

resp = requests.get(url, headers=headers)

See Customer Headers from the requests documentation

fixatd
  • 1,394
  • 1
  • 11
  • 19
  • Thanks! That works! I fiannyl get status code 200. Now I am trying to save the file I download to resp as a pdf. I am using - with open('/download/global_policy_add.pdf', 'wb') as f: f.write(resp.content) But I get error no such file. – RiptimRip May 16 '20 at 17:09
  • You might be looking for this: https://api-docs.assembla.cc/content/ref/documents_download.html – fixatd May 16 '20 at 18:01