Difference between revisions of "API Add School"

From zFairs Contest Management
Line 2: Line 2:
 
You can use our api to add schools to your contest. To do this you need to POST a message to your site. Below is an example of what needs to be posted.
 
You can use our api to add schools to your contest. To do this you need to POST a message to your site. Below is an example of what needs to be posted.
  
<syntaxhighlight lang="JavaScript" line>
+
fetch('/api/data/school', {
 +
method:'POST',
 +
headers:{'Content-Type': 'application/json'},
 +
body: JSON.stringify({
 +
Username:'admin username',
 +
Password: 'password',
 +
Body: {
 +
Name: '_ A Test School'
 +
,Address: '1219 34th State' //optional
 +
,Address2: 'Apt 3'          //optional
 +
,City: 'Ogden'              //optional
 +
,State: 'Ut'                //optional
 +
,Zip: '84403'              //optional
 +
,County: 'Weber'            //optional
 +
,Phone: '801-252-0903'      //optional
 +
,WebsiteUrl: 'zfairs.com'  //optional
 +
,SchoolType: 'Public'      //{ Public, Private, Charter, Home}  //optional
 +
,PrincipalName: 'Mrs Bell'                //optional
 +
,PrincipalPhone: '801-252-0000'            //optional
 +
,PrincipalEmail: 'MrsBell@zfairs.com'      //optional
 +
,ContactFirstName: 'Joe'                  //optional
 +
,ContactLastName: 'Homes'                  //optional
 +
,ContactPhone: '801-252-0001'              //optional
 +
,ContactEmail: 'jh@zfairs.com'            //optional
 +
,GradeLow: '0'                            //pre-k = -1, k = 0        //optional
 +
,GradeHigh: '12'                          //optional
 +
,Fax: '801-252-0003'                      //optional
 +
,SchoolPaysFees: false,                    //optional values are true/false
 +
,Id: 1234                                  //optional id of school, this will trigger an updated of that school
 +
,SchoolCode: '123'                        //optional
 +
,Affiliated: true                          //optional
 +
}
 +
})
 +
})
 +
.then(response => response.json())
 +
.then(data=>{console.log('Success: ',data);})
 +
.catch((error)=>{console.log('Error: ', error);});
  
fetch('/api/data/school', {
 
    method:'POST',
 
    headers:{'Content-Type': 'application/json'},
 
    body: JSON.stringify({
 
            Username:'admin username',
 
            Password: 'password',
 
            Body: {
 
                Name: '_ A Test School'
 
                ,Address: '1219 34th State' //optional
 
                ,Address2: 'Apt 3'          //optional
 
                ,City: 'Ogden'              //optional
 
                ,State: 'Ut'                //optional
 
                ,Zip: '84403'              //optional
 
                ,County: 'Weber'            //optional
 
                ,Phone: '801-252-0903'      //optional
 
                ,WebsiteUrl: 'zfairs.com'  //optional
 
                ,SchoolType: 'Public'      //{ Public, Private, Charter, Home}  //optional
 
                ,PrincipalName: 'Mrs Bell'                //optional
 
                ,PrincipalPhone: '801-252-0000'            //optional
 
                ,PrincipalEmail: 'MrsBell@zfairs.com'      //optional
 
                ,ContactFirstName: 'Joe'                  //optional
 
                ,ContactLastName: 'Homes'                  //optional
 
                ,ContactPhone: '801-252-0001'              //optional
 
                ,ContactEmail: 'jh@zfairs.com'            //optional
 
                ,GradeLow: '0'                            //pre-k = -1, k = 0        //optional
 
                ,GradeHigh: '12'                          //optional
 
                ,Fax: '801-252-0003'                      //optional
 
                ,SchoolPaysFees: false,                    //optional values are true/false
 
                ,Id: 1234                                  //optional id of school, this will trigger an updated of that school
 
                ,SchoolCode: '123'                        //optional
 
                ,Affiliated: true                          //optional
 
            }
 
        })
 
})
 
.then(response => response.json())
 
.then(data=>{console.log('Success: ',data);})
 
.catch((error)=>{console.log('Error: ', error);});
 
  
</syntaxhighlight>
+
 
 +
<br/><br/><br/><br/>
 +
[[Category: API]]

Revision as of 14:06, 3 November 2021

Add Schools

You can use our api to add schools to your contest. To do this you need to POST a message to your site. Below is an example of what needs to be posted.

fetch('/api/data/school', {
	method:'POST',
	headers:{'Content-Type': 'application/json'},
	body: JSON.stringify({
		Username:'admin username',
		Password: 'password',
		Body: {
			Name: '_ A Test School'
			,Address: '1219 34th State' //optional
			,Address2: 'Apt 3'          //optional
			,City: 'Ogden'              //optional
			,State: 'Ut'                //optional
			,Zip: '84403'               //optional
			,County: 'Weber'            //optional
			,Phone: '801-252-0903'      //optional
			,WebsiteUrl: 'zfairs.com'   //optional
			,SchoolType: 'Public'       //{ Public, Private, Charter, Home}  //optional
			,PrincipalName: 'Mrs Bell'                 //optional
			,PrincipalPhone: '801-252-0000'            //optional
			,PrincipalEmail: 'MrsBell@zfairs.com'      //optional
			,ContactFirstName: 'Joe'                   //optional
			,ContactLastName: 'Homes'                  //optional
			,ContactPhone: '801-252-0001'              //optional
			,ContactEmail: 'jh@zfairs.com'             //optional
			,GradeLow: '0'                             //pre-k = -1, k = 0         //optional
			,GradeHigh: '12'                           //optional
			,Fax: '801-252-0003'                       //optional
			,SchoolPaysFees: false,                    //optional values are true/false
			,Id: 1234                                  //optional id of school, this will trigger an updated of that school
			,SchoolCode: '123'                         //optional
			,Affiliated: true                          //optional 
		}
	})
})
.then(response => response.json())
.then(data=>{console.log('Success: ',data);})
.catch((error)=>{console.log('Error: ', error);});