Discussions
How to use categorised_documents with cURL in PHP
about 3 years ago by Dominik
Hello,
I'm struggling using "categorised_documents" when passing applications to Personio. With "documents" everything works as expected, but with "categorised_documents" I always get negative results.
I have tried several approaches without success:
<?php
// note: t his is an extract from a loop processing multiple files,
// $i is an incrementing integer starting with 0
// $type is either "cover-letter", "cv" or "certificate"
// this works as expected:
$data["documents[$i]"] = curl_file_create($path, $mime, $basename);
// this results in: "errors":{"categorised_category":["The categorised documents should be an array"]}
$data["categorised_documents[$i]['category']"] = $type;
$data["categorised_documents[$i]['file']"] = curl_file_create($path, $mime, $basename);
// this results in: {"error":"The provided categorised_documents are not valid, please refer to https://..."}
$data["categorised_documents[$i][category]"] = $type;
$data["categorised_documents[$i][file]"] = curl_file_create($path, $mime, $basename);
// this results in: {"error":"The provided categorised_documents are not valid, please refer to https://..."}
$data["categorised_documents"][$i]["category"] = $type;
$data["categorised_documents"][$i]["file"] = curl_file_create($path, $mime, $basename);
// the data array is added as CURLOPT_POSTFIELDS
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
Could you please point me in the right direction? Thanks!
Kind regards
Dominik