Forum Discussion

hkremer's avatar
hkremer
Helper
3 years ago

REST API Limit

Hi there,

 

I understand that the max results for LiQL query is 1000 (source).

 

However, when making a call SELECT * FROM messages limit 1000 I get hit with a 414.

 

I'm struggling to find any resources on a workaround. Can anyone provide any suggestions? Thank you!

  • Just to also add a best practise comment here, try to avoid requesting 1000 records of lots of fields, this will result in very slow api calls and have a negative effect on page load time.

    Where possible make short calls into the API and use pagination as the user needs the details. If a large call is unavoidable make it for the bare minimum fields you need.

  • hkremer, as Parshant mentioned, a 414 error indicates that the URI is too long. For example, when you perform a LiQL query using URI query parameters then it ends up looking something like this:  https://community.khoros.com/lithosphere/api/2.0/search?q=SELECT+id,+login,+avatar.profile,+rank,+view_href+FROM+users+WHERE+id+%3D+%22116946%22

    So if you are passing quite a few fields in the SELECT portion or have a lengthy WHERE clause then you could technically be hitting the URI limit.  In that case, you would need to either reach out to Khoros Support to see about increasing the URI limit or go about the query another way, such as passing the query as a JSON payload instead.

    Where are you making the query?  Is it within a FreeMarker component/macro/endpoint, or perhaps a REST API call in a script?  Or are you seeing it in the API Browser within Studio?

  • hkremer, Looks like there some issue with your instance indexing for v2 API limit, Your API code looks good to me.

    SELECT id FROM messages LIMIT 999

    If above query give you results and 1000 doesn't then this issue is with API default limit to 999.

    You should report this issue to Khoros support (support@khoros.com) team, they will help you out on this issue.

  • hkremer, can you share your code here if possible. Looks like you are doing something wrong. Since error is related to URL long or server request too long.

    • hkremer's avatar
      hkremer
      Helper
      SELECT id FROM messages LIMIT 1000

      returns

      {
          "status": "error",
          "message": "Permission Denied",
          "data": {
              "type": "error_data",
              "code": 414,
              "developer_message": "",
              "more_info": ""
          },
          "metadata": {}
      }

       

      however

       

      SELECT id FROM messages LIMIT 700

       

      returns a complete list

  • Hi Parshant - just wanted to follow up here. Do you or anyone else have any idea why I might be getting a 414? Is it throttling?

  • hkremer,

    If this API SELECT * FROM messages limit 1000 giving you the results 414

    This means you only have 414 messages available in your community (open state)

    • hkremer's avatar
      hkremer
      Helper

      Hi Parshant ,

       

      To clarify, I am getting a 414 error message "permission denied".

       

      However, when I lower the limit to 500 I get a complete response.