Skip to content

POST child logs

JeffMedeiros edited this page Nov 29, 2019 · 1 revision

Description

Register a collection of resource logs associated with a Child.

Permissions:

  • Application users can register logs of a given resource to any Child as long as the child exists.

  • A Child can register logs of a particular resource only for itself.

  • An Educator can register logs of a particular resource for any Child who exists and belongs to one of their groups.

  • A Family user can register logs of a particular resource for any Child that exists and is associated with it.

Scope

physicalactivities:create

URL

POST https://localhost/v1/children/{child_id}/logs/{resource}

Parameters

child_id: string (A 24-byte hex ID)
resource: string (steps, calories, active_minutes, lightly_active_minutes or sedentary_minutes)

Request body

[
  {
    "date": "2019-04-23",
    "value": 14100
  },
  {
    "date": "2019-04-24",
    "value": -15687
  },
  {
    "date": "2019-04-25",
    "value": 0
  },
  {
    "date": "2019-04-26",
    "value": 2901
  },
  {
    "date": "2019-04-277",
    "value": 8561
  }
]

Curl example

curl -X POST "https://localhost/v1/children/5a62be07d6f33400146c9b61/logs/steps" -H "accept: application/json" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d "[{"date":"2019-04-23","value":14100},{"date":"2019-04-24","value":15687},{"date":"2019-04-25","value":0},{"date":"2019-04-26","value":2901},{"date":"2019-04-27","value":8561}]"

Response body

  • 207 Successful request, however, can have several status codes for the case of a list of submitted logs.

    {
      "success": [
        {
          "code": 201,
          "item": {
            "date": "2019-04-23",
            "value": 14100
          }
        },
        {
          "code": 201,
          "item": {
            "date": "2019-04-25",
            "value": 0
          }
        },
        {
          "code": 201,
          "item": {
            "date": "2019-04-26",
            "value": 2901
          }
        }
      ],
      "error": [
        {
          "code": 400,
          "message": "One or more request fields are invalid...",
          "description": "value can't be negative!",
          "item": {
            "date": "2019-04-24",
            "value": -15687
          }
        },
        {
          "code": 400,
          "message": "Date parameter: 2019-04-277, is not in valid ISO 8601 format.",
          "description": "Date must be in the format: yyyy-MM-dd",
          "item": {
            "date": "2019-04-277",
            "value": 8561
          }
        }
      ]
    }
  • 400 Validation errors

    • Invalid JSON format

    • Invalid child id

    • Child does not exist

    • Missing fields

      • Example
        {
          "code": 400,
          "message": "Required fields were not provided...",
          "description": "date, value are required!"
        }
    • Invalid type

      • Example
        {
          "code": 400,
          "message": "One or more request fields are invalid...",
          "description": "The names of the allowed types are: steps, calories, active_minutes, lightly_active_minutes, sedentary_minutes."
        }
    • Invalid date

      • Example
        {
          "code": 400,
          "message": "Date parameter: {datetime}, is not in valid ISO 8601 format.",
          "description": "Date must be in the format: yyyy-MM-dd"
        }
    • Negative number

      • Example
        {
          "code": 400,
          "message": "One or more request fields are invalid...",
          "description": "value can't be negative!"
        }
    • Invalid number

      • Example
        {
          "code": 400,
          "message": "One or more request fields are invalid...",
          "description": "value must be a valid number!"
        }
  • 401 Unauthorized Error

  • 403 Permission Error

  • 429 Too Many Requests Error

  • 500 Internal Server Error

OCARIoT users

Integration endpoints

auth

users

institutions

children

children.physicalactivities

children.logs

children.sleep

children.weights

children.bodyfats

educators

educators.children.groups

families

families.children

healthprofessionals

healthprofessionals.children.groups

applications

institutions.environments

fitbit

fitbit.subscriber

users.fitbit.auth

users.fitbit.sync

Error patterns

400 Validation Errors

Clone this wiki locally