GraphQL Cannot get organization auditLog

I’m trying to fetch my organization audit logs using GraphQL queries.

I followed this guide:

https://github.blog/2019-06-21-the-github-enterprise-audit-log-api-for-graphql-beginners/

I made the this query (filled with my org-name, user-name):

{
  organization(login: "<org-name>") {
    auditLog(last: 5, query: "actor:<user-name>") {
      edges {
        node {
          ... on AuditEntry {
# Get Audit Log Entry by 'Action'
            action
            actorLogin
            createdAt
# User 'Action' was performed on
           user{
              name
                email
            }
          }
        }
      }
    }
  }
}

With the following headers:

Accepts: application/vnd.github.audit-log-preview+json
Content-Type: application/json

I receive this error:

{
  "errors": [
    {
      "path": [
        "query",
        "organization",
        "auditLog"
      ],
      "extensions": {
        "code": "undefinedField",
        "typeName": "Organization",
        "fieldName": "auditLog"
      },
      "locations": [
        {
          "line": 3,
          "column": 5
        }
      ],
      "message": "Field 'auditLog' doesn't exist on type 'Organization'"
    }
  ]
}

My guess is that the preview header is use is ignored , and I cannot access the audit log preview feature?

Anyone here encountered this issue before?

Thanks!

1 Like

Solved this issue.

Turns out the blog is a little outdated. The header should be “Accept”, and not “Accepts”.

1 Like