7. Uploading Clocking Records via API

Uploading CLOCKING Records to Go2Clock Instance


To upload records send a PUT request to the Go2Clock server.

The web address format you are going to send in is as follows...

Base URL format: app.go2clock.com/api/punches/


Header Authentication Parameter: APIKEY

Body: Is made up of JSON key pair values in the format of application/x-www-form-urlencoded,

For example... field1=value1&field2=value2&field3=value3

Example Postman Setup

Here’s how the setup would look:

  • Method: PUT
  • URL: https://app.go2clock.com/api/punches/
  • Headers:
  • APIKEY: your_api_key_here
  • Content-Type: application/x-www-form-urlencoded
  • Body (x-www-form-urlencoded):
  • userid=123
  • checktime=2024-09-01T08:00:00
  • checktype=0 (or 1 or custom number)
  • sensorid=456
  • worktype=123 (job code number)
  • latitude=40.7128
  • longitude=-74.0060
  • eventdescription=Check-in at main gate
  • deviceserial=ABC123XYZ

Example cURL command:

curl --location --request PUT 'https://app.go2clock.com/api/punches/' \
--header 'APIKEY: your_api_key_here' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'userid=123' \
--data-urlencode 'checktime=2024-09-01T08:00:00' \
--data-urlencode 'checktype=0' \
--data-urlencode 'sensorid=456' \
--data-urlencode 'worktype=123' \
--data-urlencode 'latitude=40.7128' \
--data-urlencode 'longitude=-74.0060' \
--data-urlencode 'eventdescription=Check-in at main gate' \
--data-urlencode 'deviceserial=ABC123XYZ'

Server Responses

The server will respond with an array of key values to indicate if successful or not, below is some examples...


Invalid API key response

{
"status": false,
"error": "Invalid API key "
}

Record already exists

{
"status": "failure",
"message": "",
"error": {
"userid": "The record already exists on the cloud server."
}
}

Problem with data format

{
"status": "failure",
"message": "Validation Error",
"error": "Error Description"
}

Problem with writing the data to the database

{
"status": "failure",
"message": "",
"error": "An unexpected error trying to create the record on the cloud server"
}

Successful upload

{
"status": "success",
"message": "",
"error": "Success created."
}
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us