cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
311
Views
0
Helpful
5
Replies

CER config API issues

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.

1 Accepted Solution

Accepted Solutions

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.

View solution in original post

5 Replies 5

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.

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

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''

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.

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?

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

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....