Page 1 of 1

Fetching attachments from simPRO

Posted: Thu Jul 12, 2018 11:51 pm
by ConvertworX
Hi,

We are trying to get job attachments from simPRO.

We seem to receive the file name and file ID, but we are not getting the URL to download the actual file.

Below is the code that we are using and I attach the response we receive.

Could you help me figure out what we are missing?


Thanks.

Code used:

import requests, sys
def get_attachments():
attachments = []
try:
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer <masked>'
}


resp = requests.get(
'https://durkin.simprosuite.com/api/v1.0 ... nts/files/',
headers=headers,
)

attachments = resp.json()
print attachments
except:
pass

get_attachments()

def get_specific_attachments():
attachments = []
try:
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer <masked>'
}


resp = requests.get(
'https://durkin.simprosuite.com/api/v1.0 ... 6LLxukasxU',
headers=headers,
)

attachments = resp.json()
print attachments
except:
pass

get_specific_attachments()

Re: Fetching attachments from simPRO

Posted: Fri Jul 13, 2018 12:28 am
by rick.lan
Hi ConvertworkX,

Thank you for your message, there are couple of ways to retrieve the file:

1. Receiving base64 data, in you case, you can append "?display=Base64" at the end of the url, e.g.

Code: Select all

https://durkin.simprosuite.com/api/v1.0/companies/3/jobs/13199/attachments/files/EwMCd-gwvfOp3WMxjt4GNe2nO1d-xvjxJ6LLxukasxU?display=Base64
This will give you a Base64 encoded data of the file.

2. use /view/ to access the file, e.g.

Code: Select all

https://durkin.simprosuite.com/api/v1.0/companies/3/jobs/13199/attachments/files/EwMCd-gwvfOp3WMxjt4GNe2nO1d-xvjxJ6LLxukasxU/view/
This will initiate file transfer for you.

3. use /view/?thumbnail=true to retrieve a thumbnail of the file, e.g.

Code: Select all

https://durkin.simprosuite.com/api/v1.0/companies/3/jobs/13199/attachments/files/EwMCd-gwvfOp3WMxjt4GNe2nO1d-xvjxJ6LLxukasxU/view/?thumbnail=true
This is probably not relate to what you after, but it's handy if you want to display an preview on your applcation, something like:

Code: Select all

<a href="https://durkin.simprosuite.com/api/v1.0/companies/3/jobs/13199/attachments/files/EwMCd-gwvfOp3WMxjt4GNe2nO1d-xvjxJ6LLxukasxU/view/">
<img src="https://durkin.simprosuite.com/api/v1.0/companies/3/jobs/13199/attachments/files/EwMCd-gwvfOp3WMxjt4GNe2nO1d-xvjxJ6LLxukasxU/view/?thumbnail=true" />
</a>
We have modified your post and remove the access code for security reason. : )

Please let us know if you have any other questions.

Rick

Re: Fetching attachments from simPRO

Posted: Thu Jul 23, 2020 1:37 am
by malcn
Hi Rick,

Is it possible to construct a URL link to the file that can be accessed not through the api?

Thanks

Malcolm

Re: Fetching attachments from simPRO

Posted: Fri Jul 24, 2020 12:25 am
by vaughan
Due to security of customer data, we wouldn't provide a URL that is publically accessible. The attachment must be retrieved via the API using the authorisation requirements of the API.