
298 N.W.2d 307 (1980)
Judy C. STAFFORD, Appellant,
v.
VALLEY COMMUNITY SCHOOL DISTRICT, and the individual members of the Board of Education, Ellie Medberry, Laverne Swenson, Douglas Aylsworth, Russell Friederich and Lloyd Meier, and individually the Secretary of the Board of Education, Gladys Hanson, and individually the Superintendent, Richard Burmeister, Appellees.
No. 64518.
Supreme Court of Iowa.
November 12, 1980.
*308 James L. Sayre and Mark R. Adams of Dreher, Wilson, Adams, Jensen, Sayre & Gribble, Des Moines, for appellant.
John L. Bauercamper of Jacobson, Bristol, Thomson & Bauercamper, Waukon, for appellees.
Considered by LeGRAND, P. J., and UHLENHOPP, HARRIS, McCORMICK and McGIVERIN, JJ.
McGIVERIN, Justice.
Plaintiff Judy C. Stafford appeals the district court ruling that sustained the motion of defendant school district and board to dismiss her mandamus action. She had sought to compel defendants to process her notice of appeal to an adjudicator, under section 279.17, The Code 1979, so that she could challenge defendants' decision to terminate her teaching contract. Stafford contends that the court erred in ruling that she should have challenged the defendants' decision by a writ of certiorari rather than a mandamus action. We affirm, but remand with leave to plaintiff to amend to ask for certiorari.
Defendants moved under Iowa R.Civ.P. 104(b) to dismiss Stafford's mandamus petition. For purposes of ruling on the motion, both the district court and this court are obliged to accept the facts as pleaded in the petition. Curtis v. Board of Supervisors, 270 N.W.2d 447, 448 (Iowa 1978). Stafford's allegations are construed in the light most favorable to her. Id. By moving to dismiss, defendants waived any ambiguity or uncertainty in the petition. Id.
The petition, which incorporated by reference the defendant board's decision, discloses the following facts. Stafford was first employed in November 1976 by the school district for half days on an hourly pay basis. She was responsible for tutoring one student. During the 1977-78 school year, she worked as a salaried teacher on a three-fourths time basis. For the 1978-79 school year, she was a salaried teacher on a half-time basis. On February 23, 1979, the school district began formal termination proceedings under sections 279.15, .16, The Code. After following the proper procedures, defendants decided to terminate her contract at the end of the 1978-79 school year because of a decline in the number of students.
After the decision to terminate her contract, Stafford tried to appeal the board's decision to an adjudicator under section 279.17, The Code,[1] by filing a notice of *309 appeal with the board. On April 2, 1979, the board decided that Stafford was a "probationary teacher" as defined in section 279.19[2] and therefore was not entitled to appeal the board's decision terminating her contract to an adjudicator under section 279.17. Under the board's interpretation of the master contract between the school district and the Valley Education Association of which plaintiff was a member, Stafford was not a member of the bargaining unit during the 1976-77 school year because she only taught part time and was paid on an hourly basis. Therefore, when her contract was terminated in 1979, she was still a probationary teacher because she was only in her second consecutive year of employment as a salaried teacher.
Stafford filed a petition for a writ of mandamus to compel the board to process her appeal. She claimed that under section 279.19 and under the master contract, she was a nonprobationary teacher and therefore entitled to an appeal before an adjudicator under section 279.17.
On defendants' motion, the trial court dismissed the petition for a writ of mandamus after concluding that the defendants' action should be challenged by a writ of certiorari. Stafford appealed to us. We are presented with the procedural question of whether the board's decision that Stafford was a probationary teacher is properly challenged by a petition for a writ of mandamus or a writ of certiorari. We conclude that the trial court correctly decided that certiorari, not mandamus, was the proper form of action.
A mandamus action is a special proceeding authorized by chapter 661, The Code. It is an action "to obtain an order commanding an inferior tribunal, board, corporation, or person to do or not to do an act, the performance or omission of which the law enjoins as a duty resulting from an office, trust, or station." § 661.1, The Code. Its purpose is "to enforce an established right and to enforce a corresponding duty imposed by law." Stith v. Civil Service Commission, 159 N.W.2d 806, 808 (Iowa 1968). Mandamus is not available to establish legal rights, but only to enforce legal rights that are clear and certain. Reed v. Gaylord, 216 N.W.2d 327, 332 (Iowa 1974); Headid v. Rodman, 179 N.W.2d 767, 770 (Iowa 1970).
In Stafford's case, mandamus is unavailable because she has not shown a clear and certain right to appeal the board's decision to an adjudicator under section 279.17. There is a threshold question of whether Stafford is a probationary teacher. If, as the board decided, she is a probationary teacher, she has no right to appeal to an adjudicator under section 279.17. If she is a probationary teacher, the board's decision to terminate is final unless the termination violated a constitutional right or a right under section 20.10, The Code. § 279.19. In contrast, if Stafford, as she alleges, is a nonprobationary teacher, she is entitled to appeal her termination to an adjudicator. § 279.17. With this threshold issue to be determined, Stafford has not established a clear and certain right to have her appeal to the adjudicator processed by the board.
Mandamus is also improper if there is a "plain, speedy and adequate remedy in the ordinary course of the law. . . ." § 661.7. A writ of certiorari is the type of remedy that precludes the use of a mandamus action. Reed, 216 N.W.2d at 331. We conclude that the proper way for Stafford to challenge the board's decision that she is a probationary teacher is by writ of certiorari.
Iowa R.Civ.P. 306 authorizes the issuance of a writ of certiorari "where an inferior tribunal, board or officer, exercising judicial functions, is alleged to have exceeded its, or his proper jurisdiction or *310 otherwise acted illegally." The school board may have acted illegally by incorrectly applying the law or by making findings of fact that were not supported by substantial evidence. Weldon v. Zoning Board, 250 N.W.2d 396, 400 (Iowa 1977). In its hearing on Stafford's termination and in applying the facts it found to the law, the board was exercising a judicial function that is reviewable by certiorari. Curtis, 270 N.W.2d at 449.
Having concluded that the trial court correctly ruled that certiorari, not mandamus, was the proper procedural device, we affirm the dismissal of Stafford's mandamus petition.
However, under Iowa R.Civ.P. 107, if a plaintiff brings a mandamus action where certiorari should have been used, "the court shall permit him on such terms, if any, as it may prescribe, to amend by asking for such latter remedy, which may be awarded." Under this rule, we think Stafford should be able to amend her petition to ask for a writ of certiorari and have a court reach the merits of whether the board improperly classified her as a probationary teacher. Stith, 159 N.W.2d at 809. The case is remanded with leave to plaintiff to amend her petition on terms prescribed by the trial court to ask for a writ of certiorari. Iowa R.Civ.P. 107.
AFFIRMED AND REMANDED.
NOTES
[1]  Section 279.17, The Code, provides in part:

If the teacher is no longer a probationary teacher, the teacher may, within ten days, appeal the determination of the board to an adjudicator by filing a notice of appeal with the secretary of the board. The notice of appeal shall contain a concise statement of the action which is the subject of the appeal, the particular board action appealed from, the grounds on which relief is sought and the relief sought.
[2]  Section 279.19, The Code, provides in part:

The first two consecutive years of employment of a teacher in the same school district are a probationary period. However, a board of directors may waive the probationary period for any teacher who previously has served a probationary period in another school district and the board may extend the probationary period for an additional year with the consent of the teacher.
