Hello,
I have a problem with the jamf api. The endpoint /teacher/ is not usable.
I would like to create a token. For this I try to determine the companieid.
Creating und getting classes and users works fine. But not the teacher endpoint.
I think this is a jamf-error or an error in the documentation (https://api.zuludesk.com/docs/).
So what can I do to get a teacher token. It is very frustrating.
I alway get this responce:
Response HTTP Status Code : 404
Response HTTP Body : {"error":{"code":404,"message":"Not found"}}
===================
== my code ==
===================
//very simular to: https://api.zuludesk.com/docs/
$networkid="999999999";
$apikey="GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG";
$baseurl="https://<<ourschool>>.jamfcloud.com/api";
//Don't work
$url=$baseurl.'/teacher/companies/';
$request='GET';
$body=[];
/*
//Don't work
$url=$baseurl.'/teacher/companies/';
$request='POST';
$body=['filter' => 'school name'];
*/
/*
//Works fine:
$url=$baseurl.'/users';
$request='GET';
$body=[ ];
*/
jamftest($url,$networkid,$apikey,$request,$body);
function jamftest($url,$networkid,$apikey,$request='GET', $body=[]){
echo '<br>\\n URL: '.$url.'<br>\\n';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $request);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Basic '.base64_encode($networkid.":".$apikey),
'X-Server-Protocol-Version: 3',
'Content-Type: application/x-www-form-urlencoded; charset=utf-8',
]);
// Create body when array
if( is_array($body) ) {
$body = http_build_query($body);
}
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
// Send the request & save response to $resp
$resp = curl_exec($ch);
if(!$resp) {
die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
} else {
echo "Response HTTP Status Code : " . curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo "\\nResponse HTTP Body : " . $resp;
}
curl_close($ch);
}