Build a small command-line program that migrates records from a legacy HTTP API to a new HTTP API.
POST https://auth.example.com/oauth/token
client_id
,
client_secret
,
grant_type="client_credentials"
access_token
(string)
expires_in
(seconds)
GET https://legacy.example.com/v1/records?page=<n>&page_size=<k>
Authorization: Bearer <access_token>
data
: array of records
next_page
: number or
null
Example legacy record:
{
"id": 123,
"first_name": "Ada",
"last_name": "Lovelace",
"email": "ADA@EXAMPLE.COM",
"created_at_epoch": 1700000000,
"status": "ACTIVE"
}
POST https://new.example.com/v2/records
Authorization: Bearer <access_token>
Content-Type: application/json
X-Checksum: <checksum>
Idempotency-Key: <stable-key>
Transform each legacy record into the following shape:
{
"legacy_id": 123,
"full_name": "Ada Lovelace",
"email": "ada@example.com",
"created_at": "2023-11-14T22:13:20Z",
"is_active": true
}
Rules:
legacy_id = id
full_name = first_name + " " + last_name
(trim extra spaces)
email = lowercase(email)
created_at = created_at_epoch
converted to UTC ISO-8601
is_active = (status == "ACTIVE")
Compute X-Checksum as:
SHA-256
of the
exact UTF-8 bytes
of the JSON request body you send.
(If you choose to canonicalize JSON to avoid key-order differences, explain your approach.)
next_page == null
.
Login required