This community is for technical, feature, configuration and deployment questions.
For production deployment issues, please contact the TAC! We will not comment or assist with your TAC case in these forums.
Please see How to Ask the Community for Help for other best practices.
I am new to the Cisco ISE 2.1 and trying to build an ASP.NET MVC 5 application that will create Guest Users using the Guest REST API.
While I am trying to get user details (created using sponsor portal by sponsor user "vspl"), I am able to get the information.
As I am trying to create a guest user account using the Guest REST API from my application and trying get response (HttpWebRequest.GetResponse()), an error "The remote server returned an error: (400) Bad Request." is raising. below is my code:
public string postXMLData()
destinationUrl = @"https://ise.demo.com:9060/ers/config/guestuser/";
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(destinationUrl);
request.Method = "POST"; // to create a new guest user account
request.ContentType = "application/vnd.com.cisco.ise.identity.guestuser.2.0+xml";
request.Accept = "application/vnd.com.cisco.ise.identity.guestuser.2.0+xml";
request.AutomaticDecompression = DecompressionMethods.GZip;
string credidentials = "vspl:Password"; //// "vspl is the Sponsor user"
string authCode = Convert.ToBase64String(Encoding.Default.GetBytes(credidentials)); //to convert user id and password as per RFC 2617
request.Headers.Add("Authorization", "Basic " + authCode);
//// XML data to post to the REST API's POST method
requestXml = @"<?xml version=""1.0"" encoding= ""utf-8"" standalone= ""yes""?><ns2:guestuser xmlns:ns2=""identity.ers.ise.cisco.com""><guestAccessInfo><fromDate>08/17/2016 19:01</fromDate><location>San Jose</location><toDate>11/14/2016 19:01</toDate><validDays>90</validDays></guestAccessInfo><guestInfo><company>VSPL</company><emailAddress>email@example.com</emailAddress><enabled>false</enabled><firstName>Nitin</firstName><lastName>Gupta</lastName><notificationLanguage>English</notificationLanguage><phoneNumber>9988880000</phoneNumber><smsServiceProvider>Global Default</smsServiceProvider></guestInfo><guestType>Contractor (default)</guestType><personBeingVisited>firstname.lastname@example.org</personBeingVisited><reasonForVisit>Meeting</reasonForVisit></ns2:guestuser>";
bytes = System.Text.Encoding.UTF8.GetBytes(requestXml);
request.ContentLength = bytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.Length);
//// Below line is throwing "The remote server returned an error: (400) Bad Request." error
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
if (response.StatusCode == HttpStatusCode.OK)
Stream responseStream = response.GetResponseStream();
string responseStr = new StreamReader(responseStream).ReadToEnd();
catch (Exception ex)
Can somebody help me on this.
Thanks in advance.
Just quickly looking over your request, you are missing the portalid definition in your xml. Also i believe that the customFields difinition is now mandatory in ISE 2.1. ns:2 should according to the ISE documentation be ns:3.
Example from docu :
Thanks for the reply but as per page no. 142 in api ref documentation above Table No. 7-33, only guestType is required field.
I have also tried to add Portal Id, but issue still remains.
That section does not indicate that guestType is the only required field, it just states that there has to be a guestType in the request.
Did you put an actual portalid number in the request from your ise configuration?
What did you put in the customfields section? If you don't have anything to put there, you can just use