03-14-2024 10:17 AM
I am not able to make changes via API to CER v14. I am always getting back a 400 - bad request. I got past the read portion of CER after I figured out that you have to parse out the 'Set-Cookie' header and send it back in a subsequent request as a 'Cookie' header. All my GET requests are working great. I am trying to send JSON for the request based on the documentation examples at https://developer.cisco.com/docs/cer-config/ but no joy so far. Does it actually accept JSON, or do I need to convert this to XML? I noticed the XML version for updating a user group was inside a tag of
updateUserGroupRequest
but the JSON example looks like you just send the elements like this.
cer_base_url5 = '/cerappservices/service/usergroup/'
update_group = {
"userGroupName": admg_name,
"addUsersToGroup": {
"user": [ adm_user ]
}
qupd = requests.put(cer_full_url5,auth=req_dauth,verify=False,headers=json_hdr,data=update_group)
It seems like I must missing a small detail, but I haven't been able to figure it out.
Solved! Go to Solution.
03-14-2024 01:57 PM - edited 03-14-2024 02:05 PM
After beating my head against a wall for too long, I gave up on JSON. I was able to make it work with XML. SIgh....
Edit: I think the documentation lies. Maybe V15 supports JSON, but it sure doesn't seem like V14 does.
03-14-2024 10:38 AM
Not sure this is required, in your request include a content-type header set with application/json, so this his explicitly tells the server you are sending json data, try....
json_hdr = {'Content-Type': 'application/json'}
If this does not work, print the content from requests.put call as it might provide more specific error details for you here.
Hope this helps.
03-14-2024 10:59 AM
I am not getting any content back from the failed 400 put.
update_group {'userGroupName': 'CER System Administrator', 'addUsersToGroup': {'user': ['A1-sharonhe']}}
update usergroup A1-sharonhe status code 400
URL https://fon-rc-cer01.orhs.org/cerappservices/service/usergroup/
use_hdr {'Cookie': 'JSESSIONID=D2D7D271F1A85F0DDF4DFD0F28272DEF', 'Content-Type': 'application/json'}
response content b''
03-14-2024 01:57 PM - edited 03-14-2024 02:05 PM
After beating my head against a wall for too long, I gave up on JSON. I was able to make it work with XML. SIgh....
Edit: I think the documentation lies. Maybe V15 supports JSON, but it sure doesn't seem like V14 does.
03-15-2024 03:34 AM
That would seem odd that v14 does and now v15 does not? Sadly i do not know how to get that question answered for sure, but looks like you have proved it never the less! Congrats?
03-15-2024 05:31 AM
Perhaps there is some other mystical incantation required for JSON, but I have not been able to decipher it. If that is the case, that says not so good things about the documentation....
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide