Rookie building a simple AJAX call to demo site

72 views
Skip to first unread message

mop...@fuhsd.net

unread,
Sep 29, 2015, 11:45:09 AM9/29/15
to Interfacing With Aeries
Hi All,

I Believe my code is good, but I'm only getting a 'Fail'.

I am using Visual Studio 2015 behind my District Firewall, but I am have admin privileges for Aeries and on the network.

Here is my code:

    <script>
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }

xmlhttp.onreadystatechange = function ()
  {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
    else { document.getElementById("myDiv").innerHTML = "Fail"; }
}

xmlhttp.setRequestHeader("Accept", "text/xml");
xmlhttp.send();

}
    </script>
</head>
<body>

    <h2>AJAX</h2>
    <button type="button" onclick="loadXMLDoc()">Request data</button>
    <div id="myDiv"></div>

</body>

Camden Iliff

unread,
Sep 29, 2015, 12:49:43 PM9/29/15
to interfacing...@googlegroups.com

I think I'm seeing 2 issues that you may be facing.  The first is that your script, running inside a simple HTML page, is probably running through regular HTTP.  Your request is to HTTPS and browsers will prevent cross-domain/protocol requests like that.  Changing to "http://demo.aeries.net/aeries.net/api/v2/schools" will work, but not really.  A request like that from your local web page will go through (use Fiddler and you will see the request and response), but the results won't be returned to the object XML object.  I think the browser may be blocking the content for the same reason as the HTTPS issue.  You are requesting content from a different domain.  And for security reasons, browsers don't like that.  To confirm this, I tested against a local instance of Aeries.net I have on my dev machine and the script works perfectly.

 

So in summary, you can't use javascript to do what you are trying to do.  You will need to create server-side code (or an application) where the browser's security restrictions won't inhibit your code.  Here is a sample "xmlHTTP" class written in VB.net to give you an example of how you would do this server-side.

 

 

Imports Microsoft.VisualBasic

Imports System.XML

 

Public Class XMLHTTP

 

                Protected _URL As String = ""

                Public Property URL() As String

                                Get

                                                Return _URL

                                End Get

                                Set(ByVal value As String)

                                                _URL = value

                                End Set

                End Property

 

                Public Sub New()

 

                End Sub

 

                Public Sub New(ByVal URL As String)

                                Me.URL = URL

                End Sub

 

                Public Function ReturnXML() As XmlDocument

 

                                Dim HttpWebReq As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(Me.URL)

                                HttpWebReq.Method = "GET"

 

                                Dim hwrp As System.Net.HttpWebResponse = CType(HttpWebReq.GetResponse(), System.Net.HttpWebResponse)

                                Dim s As System.IO.Stream = hwrp.GetResponseStream()

                                Dim sr As System.IO.StreamReader = New System.IO.StreamReader(s)

                                Dim responseText As String = sr.ReadToEnd()

 

                                Dim xmlDoc As New XmlDocument()

                                If responseText.Length > 0 Then              'If nothing is returned, the following statement would generate an exception, so make sure we've got something

                                                xmlDoc.LoadXml(responseText)

                                End If

                                hwrp.Close()

                                Return xmlDoc

 

                End Function

 

                Public Function ReturnXML(ByVal URL As String) As XmlDocument

 

                                Me.URL = URL

                                Return ReturnXML()

 

                End Function

 

End Class

 

 

 

 

AeriesA_64

Camden Iliff
Director of Programming

Aeries® SIS / Eagle Software

(888) 487-7555
c...@aeries.com

 

Have you seen the new Aeries Teacher Resource Center? Visit http://teacher.aeries.com/ to see all of the great resources available to teachers.

--
You received this message because you are subscribed to the Google Groups "Interfacing With Aeries" group.
To unsubscribe from this group and stop receiving emails from it, send an email to interfacing-with-...@googlegroups.com.
To post to this group, send email to interfacing...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/interfacing-with-aeries/3ecbf0de-1524-4739-aa96-55f01be7bfd9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mop...@fuhsd.net

unread,
Oct 2, 2015, 1:39:59 PM10/2/15
to Interfacing With Aeries
Thanks Cam,

This is what I have now in Visual Studio - currently getting a 404

  Function ReturnXML() As String
        Try
            MsgBox("1")

            Dim responseData As String = ""

            Dim cookieJar As New Net.CookieContainer()
            Dim hwrequest As Net.HttpWebRequest = Net.WebRequest.Create("https://demo.aeries.net/api/schools")
            Dim username As String
            Dim password As String

            username = "admin"
            password = "admin"
            Dim networkCredential As New NetworkCredential(username, password)

            hwrequest.CookieContainer = cookieJar
            hwrequest.Accept = "text/xml,*/*"
            hwrequest.AllowAutoRedirect = True
            hwrequest.UserAgent = "http_requester/0.1"
            hwrequest.Timeout = 60000
            hwrequest.Method = "GET"

            MsgBox("2")
            Dim hwresponse As Net.HttpWebResponse = hwrequest.GetResponse()
            MsgBox(hwresponse)
            If hwresponse.StatusCode = Net.HttpStatusCode.OK Then
                Dim responseStream As IO.StreamReader =
                  New IO.StreamReader(hwresponse.GetResponseStream())
                responseData = responseStream.ReadToEnd()
                Response.Text = responseData

            End If
            hwresponse.Close()
        Catch ex As Exception


        End Try
    End Function

mop...@fuhsd.net

unread,
Oct 2, 2015, 1:45:29 PM10/2/15
to Interfacing With Aeries
Never Mind, found the URL error. Success




On Tuesday, September 29, 2015 at 8:45:09 AM UTC-7, mop...@fuhsd.net wrote:

mop...@fuhsd.net

unread,
Oct 5, 2015, 11:31:24 AM10/5/15
to Interfacing With Aeries
On a similar topic, Does the API only accept certificates?  If I am doing something for my district from inside my district domain, can I not use name/password? or would I still need a certificate?

Camden Iliff

unread,
Oct 5, 2015, 12:17:00 PM10/5/15
to interfacing...@googlegroups.com

The cert is technically the only published, publicly documented way.

 

AeriesA_64

Camden Iliff
Director of Programming

Aeries® SIS / Eagle Software

(888) 487-7555
c...@aeries.com

 

Have you seen the new Aeries Teacher Resource Center? Visit http://teacher.aeries.com/ to see all of the great resources available to teachers.

 


Sent: Monday, October 5, 2015 8:31 AM
To: Interfacing With Aeries <interfacing...@googlegroups.com>

--

You received this message because you are subscribed to the Google Groups "Interfacing With Aeries" group.
To unsubscribe from this group and stop receiving emails from it, send an email to interfacing-with-...@googlegroups.com.
To post to this group, send email to interfacing...@googlegroups.com.

mop...@fuhsd.net

unread,
Oct 5, 2015, 1:35:02 PM10/5/15
to Interfacing With Aeries
Is the certificate issued from our IIS or through Aeries.net?


On Tuesday, September 29, 2015 at 8:45:09 AM UTC-7, mop...@fuhsd.net wrote:

Camden Iliff

unread,
Oct 5, 2015, 4:27:27 PM10/5/15
to interfacing...@googlegroups.com

It's all through Aeries.net on the "API Security" page.

 

AeriesA_64

Camden Iliff
Director of Programming

Aeries® SIS / Eagle Software

(888) 487-7555
c...@aeries.com

 

Have you seen the new Aeries Teacher Resource Center? Visit http://teacher.aeries.com/ to see all of the great resources available to teachers.

 

From: interfacing...@googlegroups.com [mailto:interfacing...@googlegroups.com] On Behalf Of mop...@fuhsd.net
Sent: Monday, October 5, 2015 10:35 AM
To: Interfacing With Aeries <interfacing...@googlegroups.com>
Subject: [interfacing-with-aeries] Re: Rookie building a simple AJAX call to demo site

 

Is the certificate issued from our IIS or through Aeries.net?

--

You received this message because you are subscribed to the Google Groups "Interfacing With Aeries" group.
To unsubscribe from this group and stop receiving emails from it, send an email to interfacing-with-...@googlegroups.com.
To post to this group, send email to interfacing...@googlegroups.com.

mop...@fuhsd.net

unread,
Oct 6, 2015, 10:40:59 AM10/6/15
to Interfacing With Aeries
Ok, found it. I have created a test certificate and see the certificate key. Can this be exported as a.cer file?


On Tuesday, September 29, 2015 at 8:45:09 AM UTC-7, mop...@fuhsd.net wrote:

Camden Iliff

unread,
Oct 6, 2015, 3:25:36 PM10/6/15
to interfacing...@googlegroups.com

It's not a real "Certificate".  It's just a unique, random character string you use in your requests.  Coding that in a request header is a lot easier than trying to install a real certificate, deal with trusting CAs, and creating code to use a real cert.

 

AeriesA_64

Camden Iliff
Director of Programming

Aeries SIS - Eagle Software

(888) 487-7555
c...@aeries.com

 

 

From: interfacing...@googlegroups.com [mailto:interfacing...@googlegroups.com] On Behalf Of mop...@fuhsd.net
Sent: Tuesday, October 06, 2015 7:41 AM
To: Interfacing With Aeries
Subject: [interfacing-with-aeries] Re: Rookie building a simple AJAX call to demo site

 

Ok, found it. I have created a test certificate and see the certificate key. Can this be exported as a.cer file?

--

You received this message because you are subscribed to the Google Groups "Interfacing With Aeries" group.
To unsubscribe from this group and stop receiving emails from it, send an email to interfacing-with-...@googlegroups.com.
To post to this group, send email to interfacing...@googlegroups.com.

mop...@fuhsd.net

unread,
Oct 8, 2015, 11:18:45 AM10/8/15
to Interfacing With Aeries
Ok, so now I'm trying it on my own database. I don't know if my trying this from within our domain makes a difference:







To unsubscribe from this group and stop receiving emails from it, send an email to interfacing-with-aeries+unsub...@googlegroups.com.

mop...@fuhsd.net

unread,
Oct 9, 2015, 11:55:03 AM10/9/15
to Interfacing With Aeries
I just realized we use Windows Authentication. I bet that's a problem I'm having. When I paste the URL in the browser, the windows authtentication window pops up

Camden Iliff

unread,
Oct 9, 2015, 2:21:12 PM10/9/15
to interfacing...@googlegroups.com

Your header information is wrong.  You named the certificate information the wrong name.  Please see the documentation for the proper name.

 

AeriesA_64

Camden Iliff
Director, Product Development

Aeries® SIS / Eagle Software

(888) 487-7555
c...@aeries.com

 

Have you seen the new Aeries Teacher Resource Center? Visit http://teacher.aeries.com/ to see all of the great resources available to teachers.

To unsubscribe from this group and stop receiving emails from it, send an email to interfacing-with-...@googlegroups.com.

--

You received this message because you are subscribed to the Google Groups "Interfacing With Aeries" group.

To unsubscribe from this group and stop receiving emails from it, send an email to interfacing-with-...@googlegroups.com.


To post to this group, send email to interfacing...@googlegroups.com.

Camden Iliff

unread,
Oct 9, 2015, 2:26:00 PM10/9/15
to interfacing...@googlegroups.com

Windows authentication could also be a problem.  This is why we recommend that you use your parent/student portal for API access, not your internal admin/teacher instance of Aeries.net.

 

AeriesA_64

Camden Iliff
Director, Product Development

Aeries® SIS / Eagle Software

(888) 487-7555
c...@aeries.com

 

Have you seen the new Aeries Teacher Resource Center? Visit http://teacher.aeries.com/ to see all of the great resources available to teachers.

 

Minott Opdyke

unread,
Oct 12, 2015, 10:19:40 AM10/12/15
to interfacing...@googlegroups.com
THAT WAS IT!!!!  Using the p/s portal works perfect! thanks for your help.   Looking back over the documentation I seen now where I missed it.😛

Minott Opdyke
Data Clerk
Fallbrook Union High School District

--
You received this message because you are subscribed to a topic in the Google Groups "Interfacing With Aeries" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/interfacing-with-aeries/-A0L9u9KgEU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to interfacing-with-...@googlegroups.com.

To post to this group, send email to interfacing...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages