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()
Fetching attachments from simPRO
Forum rules
- Check the documentation first. Before posting questions, please check the documentation to ensure it doesn't already cover what you need.
- No spam. All automated messages, advertisements, and links to competitor websites will be deleted immediately.
- Post in relevant sub-forums only. Messages posted in the wrong topic area will be removed and placed in the correct sub-forum by moderators.
- Respect other users. No flaming or abusing fellow forum members. Users who continue to post inflammatory, abusive comments will be deleted from the forum after two warnings are issued by moderators.
- Harassment. No threats or harassment of other users will be tolerated. Any instance of threatening or harassing behavior is grounds for deletion from the forums.
- Adult content. No profanity or pornography is allowed. Posts containing adult material will be deleted.
- Bandwidth. All images and signatures must be 500 x 500 pixels or smaller. Posts containing over-sized images and signatures will be removed.
- Illegal content. No re-posting of copyrighted materials or other illegal content is allowed. Any posts containing illegal content or copyrighted materials will be deleted.
-
ConvertworX
- Posts: 1
- Joined: Thu Jul 12, 2018 11:46 pm
Re: Fetching attachments from simPRO
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.
This will give you a Base64 encoded data of the file.
2. use /view/ to access the file, e.g.
This will initiate file transfer for you.
3. use /view/?thumbnail=true to retrieve a thumbnail of the file, e.g.
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:
We have modified your post and remove the access code for security reason. : )
Please let us know if you have any other questions.
Rick
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=Base642. 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/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=trueCode: 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>Please let us know if you have any other questions.
Rick
Rick Lan
API Developer | simPRO Software Group
API Developer | simPRO Software Group
Re: Fetching attachments from simPRO
Hi Rick,
Is it possible to construct a URL link to the file that can be accessed not through the api?
Thanks
Malcolm
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
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.
DEVELOPER CENTER