Creating Shared Reports via API

Hi!

I am trying to create a shared report via the API. The request body that I am using is based on the example at Clockify™ API Documentation.

{
  "name": "Saved report v1",
  "isPublic": true,
  "fixedDate": false,
  "type": "SUMMARY",
  "filter": {
    "dateRangeStart": "2020-05-10T00:00:00.000Z",
    "dateRangeEnd": "2020-05-16T23:59:59.000Z",
    "dateRangeType": "THIS_WEEK",
    "dateFormat": "MM/DD/YYYY",
    "timeFormat": "HOUR12",
    "weekStart": "MONDAY",
    "users": {
      "contains": "CONTAINS",
      "ids": [],
      "status": "ACTIVE"
    },
    "userGroups": {
      "contains": "CONTAINS",
      "ids": [],
      "status": "ACTIVE"
    },
    "clients": {
      "contains": "CONTAINS",
      "ids": [],
      "status": "ACTIVE"
    },
    "projects": {
      "contains": "CONTAINS",
      "ids": [],
      "status": "ACTIVE"
    },
    "tasks": {
      "contains": "CONTAINS",
      "ids": [],
      "status": "ACTIVE"
    },
    "tags": {
      "containedInTimeentry": "CONTAINS_ONLY",
      "contains": "CONTAINS",
      "ids": [],
      "status": "ACTIVE"
    },
    "billable": true,
    "description": "Filter description",
    "withoutDescription": true,
    "detailedFilter": {
      "sortColumn": "DATE",
      "page": 1,
      "pageSize": 50,
      "auditFilter": {
        "withoutProject": true,
        "withoutTask": true,
        "duration": 3600,
        "durationShorter": true
      }
    },
    "summaryFilter": {
      "groups": [],
      "sortColumn": "GROUP"
    },
    "weeklyFilter": {
      "group": "USER",
      "subgroup": "TIME"
    },
    "sortOrder": "DESCENDING",
    "exportType": "JSON",
    "rounding": false,
    "amountShown": "HIDE_AMOUNT",
    "customFields": []
  }
}

When I POST I get a 415 error (Unsupported Media Type). Any suggestions for what I might be doing wrong?

My approach with this is to just get a working request. Once I have something which at least generates a report I’ll fill in the details of the specific report that I’m trying to create.

Thanks, Andrew.

Turns out that I was not specifying the payload type (sending query from R). Sorted now. This endpoint is now supported in the {clockify} package for R at GitHub - datawookie/clockify.

1 Like

Hi Andrew,

That’s great to hear!

I am glad you got it up and running!

Also, thanks for the documentation, looks neat.

Cheers!