Showing results for 
Search instead for 
Did you mean: 

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.


Getting "The remote server returned an error: (400) Bad Request." error when trying to connect to Cisco ISE 2.1 using ASP.NET MVC Application to consume Guest REST API

Hi All,

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 = @"";
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(destinationUrl);
            request.Method = "POST";                                                                                      // to create a new guest user account
            request.ContentType = "application/";
            request.Accept = "application/";
            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=""""><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></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></personBeingVisited><reasonForVisit>Meeting</reasonForVisit></ns2:guestuser>";

            byte[] bytes;
            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();
                        return responseStr;
            catch (Exception ex)
                throw ex;
            return null;


Can somebody help me on this.

Thanks in advance.

Nitin Gupta

Rising star

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 :

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns3:guestuser name="guestUser" id="123456789" description="ERS Example user " xmlns:ns2="" xmlns:ns3="">
<key>some key</key>
<value>some value</value>
<key>another key</key>
<value>and its value</value>
<smsServiceProvider>GLobal Default</smsServiceProvider>
<sponsorUserName>Mr Spons</sponsorUserName>

Hi nielsen,

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 


Content for Community-Ad