Open Dan-eh3 opened 5 years ago
It seems like its jamf's response that is not valid JSON when the hostname contains quotation since the failure occurs while we're decoding their response according to the error you provided
You could probably be able to see that behavior in postman by putting the following header:
Accept: application/json
Which will provide you the response that is closer to what PacketFence gets since we interact with their API using JSON
If it turns up their API returns invalid JSON, that will be where it needs to be fixed
I made the change to add Accept: application/json to the Postman header. Data still looks ok to me:
{"mobile_devices":[{"id":2,"name":"Agarcia’s iPad","device_name":"Agarcia’s iPad","udid":"redacted","serial_number":"redacted","phone_number":"","wifi_mac_address":"A0:99:redacted","managed":true,"supervised":false,"model":"iPad Air 2 (Wi-Fi)","model_identifier":"iPad5,3","modelDisplay":"iPad Air 2 (Wi-Fi)","model_display":"iPad Air 2 (Wi-Fi)","username":""}]}
We have Jamf working, but have found one bug where if the device has an apostrophe (‘) in the hostname, it will fail. There is a workaround: change the device’s hostname. This is not a scalable solution, as that would translate into manually changing many hostnames.
This is what we saw in testing:
Mar 6 01:27:47 a3-05 packetfence_httpd.portal: httpd.portal(12544) INFO: [mac:a0:99:XX:XX:XX:XX] Successfully queried JAMF API for 'mobiledevices' with MAC address 'a0:99:XX:XX:XX:XX' (pf::provisioner::jamf::execute_request) Mar 6 01:27:47 a3-05 packetfence_httpd.portal: httpd.portal(12544) ERROR: [mac:a0:99:XX:XX:XX:XX] Caught exception in captiveportal::Controller::Root->dynamic_application "Wide character in subroutine entry at /usr/local/pf/lib/pf/provisioner/jamf.pm line 252." (captiveportal::PacketFence::Controller::Root::end)
So using a Postman:
We could see that Jamf accepts the apostrophe, but the way it is presented via PF, it is rejected.
We think that this could be an easy fix if the hostname is wrapped in quotations