C# Download files via the api

SOLVE
Vidar
Participant | Partner

Hi!

 

I'm looking around here in the community but can't seem to find a clear answer.

I want to be able to get the base64 of a file from Hubspot.

 

On a deal, I've added two attachments. 

Vidar_0-1617806835762.png

I'm retrieving both via the API and it works fine. Although it's strange how to retrieve them as well.

 

I get the URL of these and want to use that URL to get the base64 of those attachments. Is there a way to do this?

 

When I'm testing this via the browser I get a 404

Vidar_1-1617807047573.png

 

Do I need to use the cloud_key_hash someway or is there another endpoint for this?

 

Best Regards,

Vidar

 

 

0 Upvotes
1 Accepted solution

Accepted Solutions
MichaelC
Solution
Guide | Partner

@Vidar Sorry I have not streamed any files from hubspot before - only through other apis. 

 

@dennisedson can you reach out to the developers and ask if the URL gotten through the interface "GET /files/v3/files/{fileId}/signed-url" needs to be streamed though the code and if the stream of that generated URL require specific http headers. I know the file is only valid for a few seconds so I see no other way to do this than to stream from the generated URL. If you have any C# developer that can help its a plus but not a requirement - the question is really http related.



Need further help with integrations or business development?



Want to help me?

Go to the following links and read through the ideas. If you like them - give the idea an upvote

Upvote the following ideas:

View solution in original post

8 Replies 8
dennisedson
Community Manager

Hey @Vidar 

Going to throw a few people at this for you 😀

@gotmike , @MichaelC , @JeanAMOROS  could any of you lend a hand here?

Thanks,

Dennis




Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content
Vidar
Participant | Partner

Thanks 🙂 

0 Upvotes
gotmike
Top Contributor

sure thing. what do you mean by this?


@Vidar wrote:

 

I'm retrieving both via the API and it works fine. Although it's strange how to retrieve them as well.

Vidar
Participant | Partner

@gotmike Oh sorry, it relates to the image, I fetch both attachments on the deal. 

The reason I find it strange is that I cant just fetch attachments on a deal from what I found.

I need to do this:

Vidar_0-1617891425789.png

First crm-associations then engagements then files. But maybe this is very wrong?

0 Upvotes
MichaelC
Guide | Partner

Hi,

 

By just pasting the link into you browser you wont be able to have the correct headers in the http connection so it wont work for that reason. 

 

You need to get the file through your code by streaming the file or downloading the file using your code and to put it into a directory on your server from there. 

 

I dont know C# to help you in the actual code - but within PHP the way to stream it and add it to the server is the way it works.

 

Kind regards,

Michael



Need further help with integrations or business development?



Want to help me?

Go to the following links and read through the ideas. If you like them - give the idea an upvote

Upvote the following ideas:

Vidar
Participant | Partner

@MichaelC  Do you know which headers I need to use for it to be able to get access?

0 Upvotes
MichaelC
Solution
Guide | Partner

@Vidar Sorry I have not streamed any files from hubspot before - only through other apis. 

 

@dennisedson can you reach out to the developers and ask if the URL gotten through the interface "GET /files/v3/files/{fileId}/signed-url" needs to be streamed though the code and if the stream of that generated URL require specific http headers. I know the file is only valid for a few seconds so I see no other way to do this than to stream from the generated URL. If you have any C# developer that can help its a plus but not a requirement - the question is really http related.



Need further help with integrations or business development?



Want to help me?

Go to the following links and read through the ideas. If you like them - give the idea an upvote

Upvote the following ideas:

View solution in original post

Vidar
Participant | Partner

Thanks! I think it was the /signed-url endpoint I was looking for. 🙂 

0 Upvotes