Difference between revisions of "API Add Category"
From zFairs Contest Management
(Created page with "== Add Category == You can use our api to add categories 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....") |
|||
Line 12: | Line 12: | ||
Body: { | Body: { | ||
Name: "Category Name", | Name: "Category Name", | ||
− | NameShort: "Category | + | NameShort: "Category Abbreviation", |
Description: "", | Description: "", | ||
− | Grades: [9,10,11,12] //optional, use 0 for | + | Grades: [9,10,11,12] //optional, use 0 for kindergarten. If not set category will be open to all grades |
Id: 123 //optional, this will cause the category at this id to be updated | Id: 123 //optional, this will cause the category at this id to be updated | ||
} | } |
Revision as of 10:49, 7 November 2020
Add Category
You can use our api to add categories 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/category', {
method:'POST',
headers:{'Content-Type': 'application/json'},
body: JSON.stringify({
Username:'admin username',
Password: 'password',
Body: {
Name: "Category Name",
NameShort: "Category Abbreviation",
Description: "",
Grades: [9,10,11,12] //optional, use 0 for kindergarten. If not set category will be open to all grades
Id: 123 //optional, this will cause the category at this id to be updated
}
})
})
.then(response => response.json())
.then(data=>{console.log('Success: ',data);})
.catch((error)=>{console.log('Error: ', error);});
Remove Category
fetch('/api/data/category/remove', {
method:'POST',
headers:{'Content-Type': 'application/json'},
body: JSON.stringify({
Username:'admin username',
Password: 'password',
Body: {
Id: 123 //optional, this will cause the category at this id to be updated
}
})
})
.then(response => response.json())
.then(data=>{console.log('Success: ',data);})
.catch((error)=>{console.log('Error: ', error);});