APIs & Integrations

AMoulin
Member

Error 404 retrieve Form uploaded file

SOLVE

Hi,

 

I created a form with a form field and I'm using api to retrieve submissions of that form.

When I try to use the url given by the submission to download the file using API token it returns a 404 error, but when I open the url in a browser (while being authenticated) it correctly shows the file.

 

I put in scopes for the app :

  • forms
  • forms-uploaded-files
  • files.ui_hidden.read
  • files

I expect ony the two first scopes should be necessary.

 

Am I missing something ?

0 Upvotes
1 Accepted solution
AMoulin
Solution
Member

Error 404 retrieve Form uploaded file

SOLVE

We found that the issue came from the request client class used in our framework. This class is trying to follow itself the redirections to make the requests using final IP address instead of domain name, and it seems that at some point it looses some requested data.

View solution in original post

7 Replies 7
AMoulin
Solution
Member

Error 404 retrieve Form uploaded file

SOLVE

We found that the issue came from the request client class used in our framework. This class is trying to follow itself the redirections to make the requests using final IP address instead of domain name, and it seems that at some point it looses some requested data.

Humashankar
Key Advisor

Error 404 retrieve Form uploaded file

SOLVE

This may be because of token has no sufficient permissions to access files uploaded via forms

Humashankar VJ
HubSpot Community Champion and enthusiast | Engineering Manager
0 Upvotes
AMoulin
Member

Error 404 retrieve Form uploaded file

SOLVE

where theses permissions are configured ? I mean I'm confused, it's an app, it should have access to all by default, restriced by the scopes at most.

dsmarion
Top Contributor | Gold Partner
Top Contributor | Gold Partner

Error 404 retrieve Form uploaded file

SOLVE

Hmmm... 404 means not found, it's not a permissions issue.  That would be 401 or 403.  Can you show more info about your api call?  I am guessing something else is the culprit.

Scott Marion
Senior Developer @ Thread Connected Marketing
AMoulin
Member

Error 404 retrieve Form uploaded file

SOLVE

basically it's that :

        $headers = [
            'Authorization' => "Bearer {$this->accessToken}",
            'Content-Type' => 'application/json',
        ];
        $response = (new ExternalResourceClient())->request('GET', $url, null, $headers);

the URL is exactly the one recieved while retrieving the submission from the api calls, it looks like that :

https://api-na1.hubspot.com/form-integrations/v1/uploaded-files/signed-url-redirect/XXXXX?portalId=XXXX&sign=XXX&conversionId=XXX&filename=XXX.pdf

the same code works to retrieve submissions

the same url works on browser to get the file

 

I'm thinking i did not try without the content-type, might cause some issues

AMoulin
Member

Error 404 retrieve Form uploaded file

SOLVE

tried without the content-type, did not change anything

dsmarion
Top Contributor | Gold Partner
Top Contributor | Gold Partner

Error 404 retrieve Form uploaded file

SOLVE

Maybe.  Also not sure if you need to urlencode.  I have not used this endpoint so can't give any examples or help much further.  Maybe some else will chime in..

Scott Marion
Senior Developer @ Thread Connected Marketing