cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1884
Views
10
Helpful
12
Replies

ERS JSON vs. XML POSTs

paul
Level 10
Level 10

I am trying to create an Endpoint and assign it to a static group with ERS.  I have it working fine with XML:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<ns3:endpoint xmlns:ns2="ers.ise.cisco.com" xmlns:ns3="identity.ers.ise.cisco.com">

  <groupId>cabb7fc0-5d4d-11e7-b01c-024226b23b4f</groupId>

  <identityStore></identityStore>

  <identityStoreId></identityStoreId>

  <mac>11:22:33:44:55:66</mac>

  <portalUser></portalUser>

  <profileId>aa0e8b20-8bff-11e6-996c-525400b48521</profileId>

  <staticGroupAssignment>true</staticGroupAssignment>

  <staticProfileAssignment>false</staticProfileAssignment>

</ns3:endpoint>

I am trying to get it to work with JSON.  I thought I would just need to specify the same parameters as I did with XML:

{

  "ERSEndPoint" : {

    "groupId" : "cabb7fc0-5d4d-11e7-b01c-024226b23b4f",

    "identityStore" : "",

    "identityStoreId" : "",

    "mac" : "11:22:33:44:55:66",

    "portalUser" : "",

    "profileId" : "aa0e8b20-8bff-11e6-996c-525400b48521",

    "staticGroupAssignment" : true,

    "staticProfileAssignment" : false,

  }

}

I am getting an error at the second to last bracket close and ISE says:

Invalid JSON Input: Unexpected character ('}' (code 125)): was expecting double-quote to start field name\n at [Source: java.io.StringReader@7c32de53; line: 11, column: 4]",

Does JSON require all the fields to be present?

Thanks.

1 Accepted Solution

Accepted Solutions

hslai
Cisco Employee
Cisco Employee

You have an extra "," (comma) character ending the line:

    "staticProfileAssignment" : false,

Removing it should help.

View solution in original post

12 Replies 12

umahar
Cisco Employee
Cisco Employee

Paul,

Just yesterday I was trying to update the endpoint for a static group using XML but I was getting some error. Dint know that ISE supports JSON as well.

Could you share your complete POST request for the working XML requests ?

I am initially mocking it up in Postman (if you aren’t using this for REST testing you should). Make sure you have your Content-Type and Accept headers set to either XML or JSON.

The body I am using is exactly what I posted in my original post.

I am working on writing a C++ executable that uses libcurl to make REST calls to ISE. I am working on a scenario for SCCM reimage processes where the customer could add my executable into the process and it would do the following:

1) Find the MAC address of the primary interface on the system (Windows only).

2) Look up the MAC address in ISE to see if it exists. If it exists grab the ID.

3) Look up the endpoint identity group specified in ISE to make sure it exists and grab the ID.

4) If the MAC address exists POST an update to ISE to statically assign the MAC address to the group ID found in #3.

5) If the MAC address doesn’t exist POST an creation to ISE to add in the MAC address and statically assign it to the group in #3.

I have my C++ code finished up through 3. So now I am going to work on coding the POST.

I haven’t coded in C++ for probably 15 years so I am hacking my way through it.

Paul Haferman

Office- 920.996.3011

Cell- 920.284.9250

Also make sure that you are using a PUT when updating the Endpoint and a POST when creating one.

Paul Haferman

Office- 920.996.3011

Cell- 920.284.9250

umahar
Cisco Employee
Cisco Employee

I myself am building an API on top of ISE APIs in python.

Managed to write lot of functions but just started working on updating Identity Group yesterday

Hi Utkarsh,

Thank you for the interest.

If your API is functional, tested and has good documentation on the purpose and how to use it, kindly share it in the community for others to benefit with caveats etc.

Python is widely used by a lot of people for writing API.

Thanks

Krishnan

I would have written mine in Python as well, but my program needs to be a self-contained DOS executable. I think you can do that with Python, but it is easier with C++ and I have worked with C++ more recently than I have with Python (which is never).

I got the PUT working with XML to update an endpoint:

sendData = ":9060/ers/config/endpoint/56b46ec0-5da2-11e7-b01c-024226b23b4f";

curl_easy_setopt(curl, CURLOPT_URL, curl_url.c_str());

curl_easy_setopt(curl, CURLOPT_HTTPHEADER, curl_headers);

curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");

curl_easy_setopt(curl, CURLOPT_POSTFIELDS, sendData.c_str());

curl_result = curl_easy_perform(curl);

So I have the update working with PUT now I just need to do a POST to create a new MAC address and assign it to the endpoint identity group.

Fun stuf!!

Paul Haferman

Office- 920.996.3011

Cell- 920.284.9250

Guys if you have some examples I can post to the pages I have as well

Please post separate examples as docs

Sent from my iPhone

umahar
Cisco Employee
Cisco Employee

Paul,

Were you able to make it work with Json ?

I just made it work with XML using REST client but in python JSON would make a better.

No I haven’t gotten JSON PUTs or POSTs to work yet. I am using JSON for all my GET functions. I can’t even get the syntax to work in Postman. I will play around with it more next week. I would also like to use JSON for everything, but as long as I have it working one way or another it doesn’t matter for the application I am writing.

Paul Haferman

Office- 920.996.3011

Cell- 920.284.9250

hslai
Cisco Employee
Cisco Employee

You have an extra "," (comma) character ending the line:

    "staticProfileAssignment" : false,

Removing it should help.

Awesome that was it! I was able to do the update with Postman. Now I will have to change my code to use JSON. I was able to strip down the JSON to the bare minimum required to update the MAC with a static Identity Group:

To update an existing MAC make a PUT call to:

https://",

"staticGroupAssignment" : true

}

}

Thanks so much for pointing out that extra comma. I haven’t worked with JSON much. I never would have figured that out.

Paul Haferman

Office- 920.996.3011

Cell- 920.284.9250

hslai
Cisco Employee
Cisco Employee

I am glad that helped. Please note that bulk requests are supported with XML only at the moment.