Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find the total number of records in GET request from SNow Change Management API #305

Closed
tupyy opened this issue Feb 28, 2024 · 0 comments · Fixed by #316
Closed
Assignees
Labels
type/bug Something isn't working

Comments

@tupyy
Copy link
Contributor

tupyy commented Feb 28, 2024

This issue is about a potential problem that we have when the generic client is implemented.

Currently, when we list all the records from a service we're continuously fetching records in batch (default size is 1000) by moving the offset sysparm_offset += offset + batch_size. The loop returns when there's no more data to fetch.
To figure out when there is no data left, we rely on two conditions:

  • for Table API, the client looks for the header value x-total-count which gives the total count of items available for that request
  • for other clients, the client stops when the result list is empty.

But the Change management API link server returns a response with no headers and a weird __meta field in the results list:

curl -s "https://devxxxx.service-now.com/api/sn_chg_rest/v1/change?sysparm_query=active=false^ORDERBYnumber" --header "Accept:application/json" --user "admin":'xxxxx' | jq
{
  "result": [
    {
      "__meta": {
        "encodedQuery": "active=false^ORDERBYnumber"
      }
    }
  ]
}

The presence of this field makes the client never finish fetching items from the server.

The solution would be to introduce a custom json.JSONDecoder that removes this field when the response is parsed into a json obj.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

service.itsm.api_info

@tupyy tupyy added the type/bug Something isn't working label Feb 28, 2024
@tupyy tupyy self-assigned this Feb 28, 2024
@github-project-automation github-project-automation bot moved this to Finished in v2.5.0 Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
Status: Finished
Development

Successfully merging a pull request may close this issue.

1 participant