© 2018 Capita Business Services Ltd. All rights reserved.

Capita Education Software Solutions is a trading name of Capita Business Services Ltd. Our Registered office is 30 Berners Street, London, W1T 3LR and our registered number is 02299747. Further information about Capita plc can be found in our legal statement.

SIMS Primary Enhanced API - Attendance $Batch Write

This API is obsolete

Please use the new V3 APIs.

 

Writing back a Batch of Attendance Records (POST)

  • Attendance record batch write back endpoint:

https://pmapis.azure-api.net/sp-api-write-back-partner-live/V2/Attendance/$batch

Request headers required:

Ocp-Apim-Subscription-Key:{{subscription_key}}

Authorization:bearer {{token}}

Content-Type:multipart/mixed; boundary=batch_{{changesetID}}

{{changesetID}} – Unique identifier for the batch changeset (a new guid). The changeset id used in the request body should be included in the content type request header. The changesetID used in the header must be identical in the message body.

Please see the below example, {{changestID}} = 5692664d-a5be-4bfe-ac5b-4c711026d780.

Request body (example):

Below example includes two attendance records: attendance mark for the learner: 2cea37cb-dbb5-4ebb-b1f9-89770752c53b and 1239979c-26e6-4d42-9fe4-f571b44a5cdb for the attendable events 5f0b751f-5cdc-41f5-96b8-f568d5dfb7fc and 5f0b751f-5cdc-41f5-96b8-f568d5dfb7fc.

The Batch identifier should be included at the beginning of each record and the end of the batch. Changeset identifier beginning of each record of the changeset.

More than one changeset can be included in a batch.

A batch can be posted using more than one post.

It is important that the changesetID on the second line of the request match that of the header for a correct responce.

Similary, it should be noted that the request requires the line brakes shown in the example below for the request to succeed.

Headers:

Authorization:Bearer {{token}}
Ocp-Apim-Subscription-Key:{{subscription_key}}
Content-Type:multipart/mixed; boundary=changeset_a85b037f-ac89-4caa-b433-b5019fa9be94

Body:

--batch_33ad011e-8a56-47c2-93b4-67688f971009
Content-Type: multipart/mixed; boundary=changeset_a85b037f-ac89-4caa-b433-b5019fa9be94

--changeset_a85b037f-ac89-4caa-b433-b5019fa9be94
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 1

POST https://staging01-ms.sims.co.uk/AttendanceServiceFarm1/OData/V1/AttendanceRecords HTTP/1.1
Content-Type: application/json;odata.metadata=minimal
Prefer: return=representation
Accept: application/json;odata.metadata=minimal
Accept-Charset:UTF-8

{
"@odata.type":"#AttendanceService.Models.OData.AttendanceRecord",
"Present":true,
"Absent":false,
"Comment":"David Stott's Batch Test Mark 1 Apple X",
"Learner":"2cea37cb-dbb5-4ebb-b1f9-89770752c53b",
"AttendableEvent":"5f0b751f-5cdc-41f5-96b8-f568d5dfb7fc",
"SchoolAttendanceCode":"7e605925-bda7-4061-97fc-46f8cb477ce6",
"MinutesLate":null
}
--changeset_a85b037f-ac89-4caa-b433-b5019fa9be94
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 2

POST https://staging01-ms.sims.co.uk/AttendanceServiceFarm1/OData/V1/AttendanceRecords HTTP/1.1
Content-Type: application/json;odata.metadata=minimal
Prefer: return=representation
Accept: application/json;odata.metadata=minimal
Accept-Charset:UTF-8

{
"@odata.type":"#AttendanceService.Models.OData.AttendanceRecord",
"Present":true,
"Absent":false,
"Comment":"David Stott's Batch Test Mark 2 Pear X",
"Learner":"1239979c-26e6-4d42-9fe4-f571b44a5cdb",
"AttendableEvent":"5f0b751f-5cdc-41f5-96b8-f568d5dfb7fc",
"SchoolAttendanceCode":"7e605925-bda7-4061-97fc-46f8cb477ce6",
"MinutesLate":null
}

--changeset_a85b037f-ac89-4caa-b433-b5019fa9be94--
--batch_33ad011e-8a56-47c2-93b4-67688f971009--

Queries required for obtaining identifiers for attendable events and school attendance codes can be found at the end of this document.

Response

Response body will state whether the request was successful and the response status code(s). There will be a response including the status code for each record that was in the posted batch. If the changestID in the request head does not match the changesetID in the body the responce will contain only a 200 OK along with a batch and changeset ID, regardless of the individual record status.

Response body (example):

 

--batchresponse_3d015919-f871-486e-b515-0b39c1ab94f6
Content-Type: application/http
Content-Transfer-Encoding: binary

HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=utf-8

[{"Message":"AttendableEvent 5F0B751F-5CDC-41F5-96B8-F568D5DFB7FC not found","ErrorCode":"ATT_VAL_2","ResourceIdentifier":"","SequenceID":"6caeb82a-9b77-4e9c-ab15-e425e8311786"},{"Message":"SchoolAttendanceCode 7E605925-BDA7-4061-97FC-46F8CB477CE6 not found","ErrorCode":"ATT_VAL_3","ResourceIdentifier":"","SequenceID":"6caeb82a-9b77-4e9c-ab15-e425e8311786"}]
--batchresponse_3d015919-f871-486e-b515-0b39c1ab94f6
Content-Type: application/http
Content-Transfer-Encoding: binary

HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=utf-8

[{"Message":"AttendableEvent 5F0B751F-5CDC-41F5-96B8-F568D5DFB7FC not found","ErrorCode":"ATT_VAL_2","ResourceIdentifier":"","SequenceID":"f28b4c54-7a57-4d37-8457-270a4721cd01"},{"Message":"SchoolAttendanceCode 7E605925-BDA7-4061-97FC-46F8CB477CE6 not found","ErrorCode":"ATT_VAL_3","ResourceIdentifier":"","SequenceID":"f28b4c54-7a57-4d37-8457-270a4721cd01"}]
--batchresponse_3d015919-f871-486e-b515-0b39c1ab94f6--