Discussions

 View Only
  • 1.  API - File Attachment Download - Resource not found

    Posted 10-28-2022 15:23
      |   view attached
    Hello,

    I have a problem downloading file attachments with the API.  My current language of choice is Python.

    I have researched several articles on this topic however no joy yet.

    If I query an attachment using the following syntax I can see the file in the browser.  So I know my user token and parameters are correct.

    https://domain.quickbase.com/up/dbid/a/r_recordid/e_fileid/vversion?usertoken=user_token

    However when I use the API to try to download the file I only get "Resource not found" as a response.

    I have attached an image with my python script.

    Any help / guidance would be greatly appreciated.  

    Thanks!

    ------------------------------
    Scott Paxton
    ------------------------------


  • 2.  RE: API - File Attachment Download - Resource not found

    Posted 10-28-2022 15:26
    Sorry one typo.  I meant to type fieldID not fileID in the url example.

    ------------------------------
    Scott Paxton
    ------------------------------



  • 3.  RE: API - File Attachment Download - Resource not found

    Posted 10-31-2022 10:24
    Hi Scott,

    In the Authorization setting in headers, it appears you're just sending the token itself.  I think you meant to use:

    'Authorization': auth_str

    Hope that helps!

    ------------------------------
    Doug Henning
    ------------------------------



  • 4.  RE: API - File Attachment Download - Resource not found

    Posted 10-31-2022 10:36
    Thanks Doug,

    I tried that also however no joy. 

    Best regards,
    Scott





  • 5.  RE: API - File Attachment Download - Resource not found

    Posted 10-31-2022 12:22
    Is the file you're downloading JSON?  If not then you'll get an error with those JSON commands.  You can access the body of the response with "r.content" or "r.text" depending on the file type.


    ​r = requests.get(
    request_str,
    headers = headers
    )
    print(r.content)


    ------------------------------
    Doug Henning
    ------------------------------



  • 6.  RE: API - File Attachment Download - Resource not found

    Posted 10-31-2022 13:54
    No. The response only contains the error. 





  • 7.  RE: API - File Attachment Download - Resource not found

    Posted 10-31-2022 13:57
    I am trying to download an image 





  • 8.  RE: API - File Attachment Download - Resource not found

    Posted 01-26-2023 17:25
    Did you ever solve this? I'm running into the same issue

    ------------------------------
    Naftali Kulik
    ------------------------------



  • 9.  RE: API - File Attachment Download - Resource not found

    Posted 01-27-2023 08:38
    Yes.  In the end this works for me.

    #Get image url using your method of choice

    import urllib.request
    from PIL import Image
    from io import BytesIO

    url = urllib.request.urlopen('https://the_image_url?usertoken=' + quickbase_token)
    s = url.read()

    img = Image.open(BytesIO(s))

    img.show() #or do whatever you want with it