All..
If you are dumbfounded with the error "", then you are not alone. I just spent the last couple of days yelling at my computer and the F5 API.
If you are using "Requests: HTTP for Humans" (https://2.python-requests.org/en/master/) module/library within Python to perform http requests to the API, and you are sending JSON objects as part of the data, then they must use the syntax:
json = { “key” : “value }
NOT:
data = { “key” : “value }
Example:
Perform a "Config-Sync" with the API, and using "data=postData" you will receive
{u'errorStack': [], u'message': u'Found invalid JSON body in the request.', u'code': 400, u'apiError': 1}
Changing that to "json=postData", removes the error as it properly encodes the json data into the request.
cpURL = "https://"+aHost+"/mgmt/tm/cm"
headers = { "content-type" : "application/json",
"X-F5-Auth-Token" : str(f5AuthToken)}
postData = {"command": "run",
"utilCmdArgs": "config-sync to-group "+syncHosts[aHost] }
apiResponse = requests.post(cpURL, headers=headers, verify=False, json=postData)
Hope this helps!