I am attempting to recreate this page on iOS. The HTML POST request I require to send the search parameters is as follows:
<FORM ACTION="pw_pub_sched.p_listthislist" METHOD="post">
Using Rob's answer here I was able to create the set up the following HTTP POST request:
@IBAction func testHTTPPost(sender: AnyObject) {
let request = NSMutableURLRequest(URL: NSURL(string: "https://banner.sbcc.edu/PROD/pw_pub_sched.p_listthislist")!)
request.HTTPMethod = "POST"
let postString = "TERM=201730&TERM_DESC=Fall 2016&sel_subj=dummy&sel_day=dummy&sel_schd=dummy&sel_camp=dummy&sel_ism=dummy&sel_sess=dummy&sel_instr=dummy&sel_ptrm=%&level=CR"
request.HTTPBody = postString.dataUsingEncoding(NSISOLatin1StringEncoding)
request.HTTPShouldHandleCookies = true
let task = NSURLSession.sharedSession().dataTaskWithRequest(request) {
(data, response, error) in
guard error == nil && data != nil else { // check for fundamental networking error
print("error=\(error)")
return
}
if let httpStatus = response as? NSHTTPURLResponse where httpStatus.statusCode != 200 { // check for http errors
print("statusCode should be 200, but is \(httpStatus.statusCode)")
print("response = \(response)")
}
let responseString = NSString(data: data!, encoding: NSUTF8StringEncoding)
print("responseString = \(responseString)")
}
task.resume()
}
However I receive a 404 error every time. This is the output:
statusCode should be 200, but is 404
response = Optional(<NSHTTPURLResponse: 0x7f8e398d2410> { URL: https://banner.sbcc.edu/PROD/pw_pub_sched.p_listthislist } { status code: 404, headers {
Connection = "Keep-Alive";
"Content-Length" = 215;
"Content-Type" = "text/html; charset=iso-8859-1";
Date = "Fri, 27 May 2016 19:23:23 GMT";
"Keep-Alive" = "timeout=5, max=100";
Server = "Oracle-Application-Server-11g";
} })
responseString = Optional(<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /PROD/pw_pub_sched.p_listthislist was not found.</p>
</body></html>
)
When I try to go directly to https://banner.sbcc.edu/PROD/pw_pub_sched.p_listthislist in my browser I also come up with a 404 error. Only by using the submit button on the search page do I successfully view the results page. However I have tried doing a request to the search page directly and also received a 404 error which leads me to believe it is my code. Is there somewhere else I should be sending this request? Why does this page seemingly not exist unless I go through the search page?