Postman API Help for SetPunch API

Discussion for TimeTrex open source community developers.
Post Reply
futurepochsols
Posts: 1
Joined: Sun Apr 26, 2020 11:13 pm

Postman API Help for SetPunch API

Post by futurepochsols »

Hi,
I'm facing an error in the SetPunch/SetUserPunch API when I try it from Postman.
This is the REST URL and the JSON payload (in "raw" format in Postman) :
http://myserver:8085/api/json/api.php?C ... tPunch&v=2
JSON Payload:
{
"0": [
{
"status_id": 10,
"type_id": "10",
"user_id": "059dbf8a-ae49-697c-b414-640f92ffe1bc",
"punch_time": "11:51+AM",
"branch_id": "00000000-0000-0000-0000-000000000000",
"department_id": "059dd231-1869-ad3c-1e3d-640f92ffe1bc",
"job_id": "00000000-0000-0000-0000-000000000000",
"job_item_id": "00000000-0000-0000-0000-000000000000",
"time_stamp": false,
"punch_date": "07-Apr-20",
"first_last_name": false,
"date_stamp": false,
"total_time": false,
}
],
"1": false,
"2": false
}


The error returned is as follows:

{
"api_retval": false,
"api_details": {
"code": "VALIDATION",
"description": "INVALID DATA",
"record_details": {
"total": 1,
"valid": 0,
"invalid": 1
},
"user_generic_status_batch_id": false,
"request": false,
"pager": false,
"details": [
{
"error": {
"status_id": [
"Incorrect Status",
"Status not specified"
],
"type_id": [
"Incorrect Type",
"Type not specified"
],
"punch_time": [
"Incorrect time stamp"
],
"time_stamp": [
"Time stamp not specified"
]
}
}
]
}
}


I've tried the sending the payload in form-data and x-www-form-urlencoded too, doesn't work.

Postman is v6.7.4.
Any help would be appreciated.

Thanks!
shaunw
Posts: 7839
Joined: Tue Sep 19, 2006 2:22 pm

Re: Postman API Help for SetPunch API

Post by shaunw »

The JSON payload must be sent as a "json" post variable, such as this:

Code: Select all

json="{ "0": [ {"status_id": 10, ...}], "1": false, "2": false }"
Please see the API documentation for more examples, including detailed PostMan examples:
https://www.timetrex.com/workforce-management-api
Post Reply