Discussions

Ask a Question
Back to All

POST Attendances

why does this transfer not work? (Employee ID and token have been replaced)


[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]'Tls11,Tls12'
$headers=@{}
$headers.Add("accept", "application/json")
$headers.Add("content-type", "application/json")
$headers.Add("authorization", "$Token")

$response = Invoke-WebRequest -Uri 'https://api.personio.de/v1/company/attendances' -Method POST -Headers $headers -ContentType 'application/json' -Body '{"attendances":[{"employee":XXXXXXX,"date":"2024-01-18","start_time":"06:37","end_time":"16:47","break":45,"comment":"Test5 Übertragung von TA Zeitblick"},{"employee":XXXXXXX,"date":"2024-01-19","start_time":"06:35","end_time":"15:37","break":30,"comment":"Test6 Übertragung von TA Zeitblick"}]}'

Server response
Invoke-WebRequest : Der Remoteserver hat einen Fehler zurückgegeben: (400) Ungültige Anforderung.
In D:\Scripte\TA_Zeitblick_Archiv\Hilfe\Personio\Anwesenheiten_nach_Personio_uebertragen_JSON.PS1:55 Zeichen:13

  • $response = Invoke-WebRequest -Uri 'https://api.personio.de/v1/compan ...
    • CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    • FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

{"success":true,"data":{"token":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX","expires_in":86400,"scope":"employees:read employees:write attendances:read attendances:write absences:read absences:write documents
:read documents:write reports.custom:read reports.custom:write"}}

Thanks Bert