Forum Discussion
Create node fails
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!
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com