Pdf file received via api

I am sending the file to tape via API without any problems
but when I try to view the file on tape itself it displays the message ā€œfailed to load PDF documentā€
but when I download the file and upload it again to tape manually the display works perfectly

Hi Joao,
Maybe this has to do with the fact that your pdf already has the pdf extension in the filename and there is an additional .pdf being appended. Have you noticed this (the two .pdf in the filename)? Maybe this could be producing the issue.

Have you tried simply changing the name deleting one of the ā€œ.pdfā€? This can be happening because somehow the extension is not being shown on upload and .pdf is automatically being added (but not at all sure without more info). If this is the case try to clearly show the extension in the filename before upload and then retest.

I hope this helps you.

Best,
R.J.

2 Likes

I just noticed another dot in the ā€œ4.00ā€, maybe this is producing the problem, you could try to remove it or changing it with another character before the upload and then retest.

1 Like

Thanks for the help, I’ll try to review the code for testing but using the same file that I downloaded directly from tape and it’s not being displayed, and uploading it again the visualization works, see example

1 Like

Hi Joao,
I am not sure I understand your reply correctly. Maybe the uploads are being treated differently (more strictly, or literally) depending on where the upload is being made through the API or manually. Although I would strongly recommend to check the code and make more tests with the filename. Don’t forget to check different browsers (with different cores ideally, chromium, firefox…) in order to discard some random browser bugs.

Best,
R.J.

sorry for the delay and thanks for the help, but I just ran the test using a file with a normal name via API and I had the same result, I used a test field for validation


Here is the code I used with the security information properly hidden
url = ā€œhttps://api.tapeapp.com/v1/file/uploadā€
headers = {}
auth_token = token
most_recent_file = r"C:\Users\joaom\Downloads\1107 t4.pdf"
with open(most_recent_file, ā€˜rb’) as file:
files = {ā€˜file’: file}
response = requests.post(
url,
headers=headers,
auth=(auth_token, ā€˜ā€™),
files=files
)

    response_json = response.json()
    file_id = response_json.get('file_id')
    url2 = f"https://api.tapeapp.com/v1/record/{record_ID}"
    headers = {"Content-Type": "application/json"}
    data = {
            "fields": {
                "file_test": file_id
            }
        }

    response = requests.put(
            url2,
            headers=headers,
            auth=(auth_token, ''),
            json=data
        )
1 Like

Hi Joao,
You are welcome. If so, I’m sorry, but I’m not sure what to suggest next.

Best,
R.J.