Forms API - Associated hidden file with form

Occasional Contributor

Hi,

 

I would to know how can I associate a hidden file with a form. What I'm doing at the moment is:

 

1 - I upload the file via the Files API. This file is marked as hidden

2 - I associate the URL returned with the form.

 

This is not working because the URL returned gives a 404. I've tried to add the signed url (https://api.hubspot.com/filemanager/api/v2/files/xxxxxxxxxxxx/signed-url-redirect?portalId=xxxxx)

 

But, when trying to see the submission on my dashboard, it crashes the interface

 

Could you please help me? 

Reply
0 Upvotes
11 Replies 11
HubSpot Moderator

Hey @SHCC,

 

Could you elaborate further on how you're associating the URL returned with a HubSpot form submission?

 

Are you passing the URL as a form field into a contact property on the form submission?

 

If so, could you share with me your portal ID and form name in question? 

Reply
0 Upvotes
Occasional Contributor

Hey Wendy,

 

Thanks for helping out.

 

I'm doing like this:

 

{
  ...
  "fields": [
    {
        "name": "firstname",
        "value": "John"
    },
    {
        "name": "lastname",
        "value": "Doe"
    },
    {
        "name": "email",
        "value": "john@example.com"
    },
    {
        "name": "multiple_checkboxes",
        "value": "value_one;value_two"
    },
    {
        "name": "file",
        "value": "https://api.hubspot.com/filemanager/api/v2/files/xxxxxxxxxxxx/signed-url-redirect?portalId=6956483"
    }
  ]
  ...
}

The portal ID is 6956483

The form ID is 5fe0dc2c-c56d-47f3-982f-7b6adeb73659

 

Please, let me know if you need more information

Reply
0 Upvotes
HubSpot Moderator

Hey @SHCC,

 

It looks like it is showing 404 because there's two file links on the file URL. In this case, I'll have to dig deeper on whether we support submission of multiple files on our Form APIs. I'll keep you posted here!

Reply
0 Upvotes
Occasional Contributor

Hey @WendyGoh 

 

That issue is related with the multi files upload. That's why I've created 2 tickets to avoid mixing up issues. Let's stick to the hidden file issue.

 

Regarding the hidden file, please check the submission ID f5503208-e869-40aa-be7c-b06867663592

 

There I associated the following URL with file field: 

https://api.hubspot.com/filemanager/api/v2/files/{file_id}/signed-url-redirect?portalId=6956483

And this is what I get when trying to open that submission.

Screenshot 2020-05-28 at 12.40.51.png

 

 

Reply
0 Upvotes
HubSpot Moderator

Hey @SHCC,

 

When looking to pass multi files using the HubSpot Form APIs, you would need to send the same field for each files, something like this:

 

var data ={
   "fields":[
      {
         "name":"email",
         "value":"getEmail"
      },
      {
         "name":"filemulti",
         "value":"https://file-url.jpg"
      },
      {
         "name":"filemulti",
         "value":"https://file-url2.jpg"
      ]
   }

Let me know if this works for you!

Reply
0 Upvotes
Occasional Contributor

Thanks @WendyGoh ! That seems to fix the issue related with the multi-file upload. One down!

 

Now regarding the hidden files. How can I upload a hidden file and associate them with the form?

 

Reply
0 Upvotes
HubSpot Moderator

Hey @SHCC,

 

Could you share with me the file ID and the file URL?

Reply
0 Upvotes
Occasional Contributor

Hey @WendyGoh 

 

I just figured out that by hidden, the files are just not shown on the file manager dashboard.

 

What I really want to achieve here, is to be able to upload files and set them private. Like this option you have here:

 

Screenshot 2020-05-29 at 17.16.24.png

 

Could you tell me how can I make this via the files API?

 

My use case is very simple: a user uploads a file via a form. This file needs to be private.

 

Reply
0 Upvotes
HubSpot Moderator

Hey @SHCC,

 

Thanks for sharing your use case in more detail.

 

Currently, it is not possible to set a file as private via the files API. Your best workaround is to create the file (without setting to hidden == true) via the files API > on the UI > set the file to private > grab the internal file URL > pass it along via the Forms API.

Reply
0 Upvotes
Occasional Contributor

Hey @WendyGoh 

 

Thanks for help. It's a shame this is not possible. I'm sure we're not the only ones with a similar use case.

 

Any chance of adding this to the roadmap? It's would be very useful feature

Reply
0 Upvotes
HubSpot Moderator

Hey @SHCC,

 

While I couldn't locate an exisiting idea forum, if you haven't already, I'd recommend jumping over to the HubSpot Ideas Forum and posting this idea there so that it's visible to the HubSpot product team and other HubSpot customers and developers. Hopefully this will gather more interest.

Reply
0 Upvotes