APIs & Integrations

Anya23
Contributor

Getting error on endpoint files/v3/files/search when using after parameter

SOLVE

When I send a request to the api, formatted as follows:

https://api.hubapi.com/files/v3/files/search?parentFolderId=<myFolderId>&limit=100

I get the expected response, a list of files.  However, when I add the after parameter as follows:

https://api.hubapi.com/files/v3/files/search?parentFolderId=<myFolderId>&limit=100&after=25

I get the following error message if the after value is at least 10 :

Invalid input JSON on line -1, column -1: Cannot construct instance of `com.hubspot.content.filemanager.core.external.requests.files.FileSearchQuery`, problem: `java.nio.BufferUnderflowException`
 
And the following if it is 0-9:
Invalid input JSON on line -1, column -1: Cannot construct instance of `com.hubspot.content.filemanager.core.external.requests.files.FileSearchQuery`, problem: Input byte[] should at least have 2 bytes for base64 bytes
 
I've tried several different values for after (0, 1,9, 25, 100, 1000) and get the above error messages for each. 
 
What am I doing wrong?
In addendum, is there an endpoint that will give me a complete list of only the filenames?  This endpoint, with all the extraneous information and the limit of 100 is not exactly what I really need.
0 Upvotes
1 Accepted solution
Jaycee_Lewis
Solution
Community Manager
Community Manager

Getting error on endpoint files/v3/files/search when using after parameter

SOLVE

Hey, @Anya23  👋 Can you try a quick test with me?

  • Make a request without the after value
  • Set the limit to 1 to keep the response small
  • Post the request and response here

I think the issue is what you are putting in for the after value. It's not a number you set, but a value returned in the response that the API generates per request.

 

My example:

Request

 

curl --request GET \
  --url 'https://api.hubapi.com/files/v3/files/search?limit=1' \
  --header 'authorization: Bearer YOUR_ACCESS_TOKEN'

 

Response

 

HTTP 200

{
  "results": [
    {
      "id": "31019226246",
      "createdAt": "2020-06-20T19:15:47.204Z",
      "updatedAt": "2021-04-26T15:20:47.005Z",
      "archived": false,
      "name": "miti-MRb1aJIwCJs-unsplash",
      "path": "miti-MRb1aJIwCJs-unsplash.jpg",
      "size": 1214282,
      "height": 4005,
      "width": 4316,
      "encoding": "jpeg",
      "type": "IMG",
      "extension": "jpg",
      "defaultHostingUrl": "https://7317559.fs1.hubspotusercontent-na1.net/hubfs/7317559/miti-MRb1aJIwCJs-unsplash.jpg",
      "url": "https://7317559.fs1.hubspotusercontent-na1.net/hubfs/7317559/miti-MRb1aJIwCJs-unsplash.jpg",
      "isUsableInContent": true,
      "access": "PUBLIC_INDEXABLE",
      "fileMd5": "7e76292a77a35a42f9e67f28d2ace7c5",
      "sourceGroup": "CONTENT"
    }
  ],
  "paging": {
    "next": {
      "after": "AAAAAQ",
      "link": "https://api.hubapi.com/files/v3/files/search?hs_static_app=endpoint-reference-ui&hs_static_app_version=1.5656&limit=1&after=AAAAAQ"
    }
  }
}

 

Follow-up request using the provided `after` value

 

curl --request GET \
  --url 'https://api.hubapi.com/files/v3/files/search?after=AAAAAQ&limit=1' \
  --header 'authorization: Bearer YOUR_ACCESS_TOKEN'

 

Response using the provided `after` value

 

HTTP 200

{
  "results": [
    {
      "id": "34275364156",
      "createdAt": "2020-08-30T03:55:31.798Z",
      "updatedAt": "2020-08-30T03:55:31.798Z",
      "archived": false,
      "name": "danielle-macinnes-IuLgi9PWETU-unsplash",
      "path": "danielle-macinnes-IuLgi9PWETU-unsplash.jpg",
      "size": 34425,
      "height": 427,
      "width": 640,
      "encoding": "jpeg",
      "type": "IMG",
      "extension": "jpg",
      "defaultHostingUrl": "https://7317559.fs1.hubspotusercontent-na1.net/hubfs/7317559/danielle-macinnes-IuLgi9PWETU-unsplash.jpg",
      "url": "https://7317559.fs1.hubspotusercontent-na1.net/hubfs/7317559/danielle-macinnes-IuLgi9PWETU-unsplash.jpg",
      "isUsableInContent": true,
      "access": "PUBLIC_INDEXABLE",
      "fileMd5": "2e0f4d3f552f5eb08c00f536e719d10d",
      "sourceGroup": "CONTENT"
    }
  ],
  "paging": {
    "next": {
      "after": "AAAAAg",
      "link": "https://api.hubapi.com/files/v3/files/search?hs_static_app=endpoint-reference-ui&limit=1&after=AAAAAg&hs_static_app_version=1.5656"
    }
  }
}

 

 

I hope this helps get you moving forward! — Jaycee

 


HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates.
Learn More.


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !

View solution in original post

2 Replies 2
Jaycee_Lewis
Solution
Community Manager
Community Manager

Getting error on endpoint files/v3/files/search when using after parameter

SOLVE

Hey, @Anya23  👋 Can you try a quick test with me?

  • Make a request without the after value
  • Set the limit to 1 to keep the response small
  • Post the request and response here

I think the issue is what you are putting in for the after value. It's not a number you set, but a value returned in the response that the API generates per request.

 

My example:

Request

 

curl --request GET \
  --url 'https://api.hubapi.com/files/v3/files/search?limit=1' \
  --header 'authorization: Bearer YOUR_ACCESS_TOKEN'

 

Response

 

HTTP 200

{
  "results": [
    {
      "id": "31019226246",
      "createdAt": "2020-06-20T19:15:47.204Z",
      "updatedAt": "2021-04-26T15:20:47.005Z",
      "archived": false,
      "name": "miti-MRb1aJIwCJs-unsplash",
      "path": "miti-MRb1aJIwCJs-unsplash.jpg",
      "size": 1214282,
      "height": 4005,
      "width": 4316,
      "encoding": "jpeg",
      "type": "IMG",
      "extension": "jpg",
      "defaultHostingUrl": "https://7317559.fs1.hubspotusercontent-na1.net/hubfs/7317559/miti-MRb1aJIwCJs-unsplash.jpg",
      "url": "https://7317559.fs1.hubspotusercontent-na1.net/hubfs/7317559/miti-MRb1aJIwCJs-unsplash.jpg",
      "isUsableInContent": true,
      "access": "PUBLIC_INDEXABLE",
      "fileMd5": "7e76292a77a35a42f9e67f28d2ace7c5",
      "sourceGroup": "CONTENT"
    }
  ],
  "paging": {
    "next": {
      "after": "AAAAAQ",
      "link": "https://api.hubapi.com/files/v3/files/search?hs_static_app=endpoint-reference-ui&hs_static_app_version=1.5656&limit=1&after=AAAAAQ"
    }
  }
}

 

Follow-up request using the provided `after` value

 

curl --request GET \
  --url 'https://api.hubapi.com/files/v3/files/search?after=AAAAAQ&limit=1' \
  --header 'authorization: Bearer YOUR_ACCESS_TOKEN'

 

Response using the provided `after` value

 

HTTP 200

{
  "results": [
    {
      "id": "34275364156",
      "createdAt": "2020-08-30T03:55:31.798Z",
      "updatedAt": "2020-08-30T03:55:31.798Z",
      "archived": false,
      "name": "danielle-macinnes-IuLgi9PWETU-unsplash",
      "path": "danielle-macinnes-IuLgi9PWETU-unsplash.jpg",
      "size": 34425,
      "height": 427,
      "width": 640,
      "encoding": "jpeg",
      "type": "IMG",
      "extension": "jpg",
      "defaultHostingUrl": "https://7317559.fs1.hubspotusercontent-na1.net/hubfs/7317559/danielle-macinnes-IuLgi9PWETU-unsplash.jpg",
      "url": "https://7317559.fs1.hubspotusercontent-na1.net/hubfs/7317559/danielle-macinnes-IuLgi9PWETU-unsplash.jpg",
      "isUsableInContent": true,
      "access": "PUBLIC_INDEXABLE",
      "fileMd5": "2e0f4d3f552f5eb08c00f536e719d10d",
      "sourceGroup": "CONTENT"
    }
  ],
  "paging": {
    "next": {
      "after": "AAAAAg",
      "link": "https://api.hubapi.com/files/v3/files/search?hs_static_app=endpoint-reference-ui&limit=1&after=AAAAAg&hs_static_app_version=1.5656"
    }
  }
}

 

 

I hope this helps get you moving forward! — Jaycee

 


HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates.
Learn More.


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !
Jaycee_Lewis
Community Manager
Community Manager

Getting error on endpoint files/v3/files/search when using after parameter

SOLVE

To your followup question, this is the available endpoint for returning files. In this case, there isn't a way to limit the properties returned. You'll need to parse out what you need in your app.

 

Best,

Jaycee


HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates.
Learn More.


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !
0 Upvotes