AnsweredAssumed Answered

REST API - "fields" param brakes returned dataset in some situations

Question asked by Piotr Boniecki on Jan 8, 2020
Latest reply on Jan 10, 2020 by Piotr Boniecki

Hi,

 

I think something does not work right with "fields" param (https://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_9.0/Integration/Web_Services/REST_API/E… ). It works as expected when I use "fields=title":

 

→ curl -s -H "oauth-token: $TOKEN" "https://$SUBDOMAIN.demo.sugarcrm.eu/rest/v11_4/Contacts?max_num=1&offset=0&order_by=date_entered:ASC&fields=title" | jq 
{
  "next_offset": 1,
  "records": [
    {
      "id": "6315c532-ffbd-11e9-b68b-0a663f8e34f2",
      "date_modified": "2020-01-03T09:17:41+00:00",
      "title": "Mgr Operations",
      "locked_fields": [],
      "_acl": {
        "fields": {}
      },
      "_module": "Contacts"
    }
  ]
}

 

I received one element (as expected) and "next_offset" is equal 1 (also as expected). But it looks differently when "fields=accept_status_calls" is used:

 

→ curl -s -H "oauth-token: $TOKEN" "https://$SUBDOMAIN.demo.sugarcrm.eu/rest/v11_4/Contacts?max_num=1&offset=0&order_by=date_entered:ASC&fields=accept_status_calls" | jq
{
  "next_offset": -1,
  "records": [
    {
      "id": "6315c532-ffbd-11e9-b68b-0a663f8e34f2",
      "date_modified": "2020-01-03T09:17:41+00:00",
      "accept_status_calls": "none",
      "locked_fields": [],
      "_acl": {
        "fields": {}
      },
      "_module": "Contacts"
    },
    {
      "id": "63d93e72-ffbd-11e9-abc8-0a663f8e34f2",
      "date_modified": "2019-11-05T11:13:41+00:00",
      "accept_status_calls": "none",
      "locked_fields": [],
      "_acl": {
        "fields": {}
      },
      "_module": "Contacts"
    }
  ]
}

 

I got two elements (which is not a number I requested) but it's not so big problem. The bigger problem is "next_offset" which equals "-1" and suggests that there is not more contacts, which is not true (there is 316 contacts in total). Here is a proof:

 

→ curl -s -H "oauth-token: $TOKEN" "https://$SUBDOMAIN.demo.sugarcrm.eu/rest/v11_4/Contacts?max_num=2&offset=0&order_by=date_entered:ASC&fields=accept_status_calls" | jq
{
  "next_offset": -1,
  "records": [
    {
      "id": "6315c532-ffbd-11e9-b68b-0a663f8e34f2",
      "date_modified": "2020-01-03T09:17:41+00:00",
      "accept_status_calls": "none",
      "locked_fields": [],
      "_acl": {
        "fields": {}
      },
      "_module": "Contacts"
    },
    {
      "id": "63d93e72-ffbd-11e9-abc8-0a663f8e34f2",
      "date_modified": "2019-11-05T11:13:41+00:00",
      "accept_status_calls": "none",
      "locked_fields": [],
      "_acl": {
        "fields": {}
      },
      "_module": "Contacts"
    },
    {
      "id": "6461835e-ffbd-11e9-9bd9-0a663f8e34f2",
      "date_modified": "2019-11-05T11:13:41+00:00",
      "accept_status_calls": "none",
      "locked_fields": [],
      "_acl": {
        "fields": {}
      },
      "_module": "Contacts"
    }
  ]
}

 

It's not broken only for "accept_status_calls" but also for few other fields. It looks like "next_offset" is not reliable enough to detect if there are more pages to fetch or not.

Outcomes