MaaS API with Python - op-allocate - getting a 500 error - wrong content type

I sorted it out by changing the type of data passed to requests:

payload = {"system_id": machine_id}
maas.post(
    url,
    data=payload,
    verify=False,
).raise_for_status()

Note the datainstead of the jsonpayload.