APIs & Integrations

AMoulin
Membre

Error 404 retrieve Form uploaded file

Résolue

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 Votes
1 Solution acceptée
AMoulin
Solution
Membre

Error 404 retrieve Form uploaded file

Résolue

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.

Voir la solution dans l'envoi d'origine

7 Réponses
AMoulin
Solution
Membre

Error 404 retrieve Form uploaded file

Résolue

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
Contributeur de premier rang

Error 404 retrieve Form uploaded file

Résolue

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 Votes
AMoulin
Membre

Error 404 retrieve Form uploaded file

Résolue

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
Contributeur de premier rang | Partenaire solutions Gold
Contributeur de premier rang | Partenaire solutions Gold

Error 404 retrieve Form uploaded file

Résolue

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
Membre

Error 404 retrieve Form uploaded file

Résolue

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
Membre

Error 404 retrieve Form uploaded file

Résolue

tried without the content-type, did not change anything

dsmarion
Contributeur de premier rang | Partenaire solutions Gold
Contributeur de premier rang | Partenaire solutions Gold

Error 404 retrieve Form uploaded file

Résolue

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