Can't get Freshsales attachment URL

Hi team!

According to List all Files and Links endpoint from Freshsales, it should return the temporary URL for the attachments, but I’m only getting like this:

GET:

https://domain.myfreshworks.com/crm/sales/api/deals/16001435608/document_associations

{
	"documents": [
		{
			"id": 16000151188,
			"url": "/documents/16000151188",
			"thumbnail_url": null,
			"name": "nicolas.jpg",
			"is_shared": true,
			"content_file_size": 442796,
			"content_content_type": "image/jpeg",
			"content_updated_at": "2022-06-24T14:19:40-04:00",
			"content_file_size_readable": "432.42 KB",
			"created_at": "2022-06-24T14:19:40-04:00",
			"is_attached": false,
			"creater_id": 16000035571
		},
		{
			"id": 16000151176,
			"url": "/documents/16000151176",
			"thumbnail_url": null,
			"name": "PowerBiDeskManual.pdf",
			"is_shared": true,
			"content_file_size": 719705,
			"content_content_type": "application/pdf",
			"content_updated_at": "2022-06-24T14:14:14-04:00",
			"content_file_size_readable": "702.84 KB",
			"created_at": "2022-06-24T14:14:14-04:00",
			"is_attached": false,
			"creater_id": 16000035571
		}
	],
	"users": [
		{
			"id": 16000035571,
			"display_name": "Samuel Pares",
			"email": "samuel@loupen.com.br",
			"is_active": true,
			"work_number": null,
			"mobile_number": null
		}
	],
	"document_associations": [
		{
			"id": 16000208857,
			"created_at": "2022-06-24T14:19:40-04:00",
			"attachable": {
				"type": "document",
				"id": 16000151188
			},
			"creater_id": 16000035571
		},
		{
			"id": 16000208845,
			"created_at": "2022-06-24T14:14:14-04:00",
			"attachable": {
				"type": "document",
				"id": 16000151176
			},
			"creater_id": 16000035571
		}
	],
	"meta": {
		"total_pages": 1,
		"total": 2
	}
}

How can I get the correct URL?

Hi @samuelpares

Looks like the response for this endpoint has changed to return the “URL” of the document which could be used to download the document.
I tried following Endpoint and it downloaded the document/file for me.

(https://freshworkcrmdomain.myfreshworks.com/crm/sales/api/{{**URL_RETURNED_FROM_DOC_ASSOC_API**}})

Unfortunately I could not find this documented in official API documentation page. Hope this helps

1 Like

@samuelpares

If you can confirm for us, the solution provided by @Sachin_Kumar is working for you, I will report this to the Freshsales team to fix their documentation.

1 Like

Hi, @Sachin_Kumar, thank you for your support!
@Saif yes… it worked.
But what I need is just to get the URL for the file, and by making the request as @Sachin_Kumar suggested, I’m being redirected to the file.
So I can’t use FDK request method to do it.
Using axios is a bit of overwork, since it does not allow to disable redirects, so I have to make the request, it will return the file, and to get the URL, I need to access response.request.res.responseUrl.
It seems that fetch lib allows to disable redirects, but you can see that it would be much simpler if the endpoint would return me the URL, as it is specified in the current documentation, and as freshdesk api works as well
So instead of fixing the documentation, I would suggest to fix the endpoint :slight_smile: