Difference between revisions of "API Add Category"
From zFairs Contest Management
Line 8: | Line 8: | ||
headers:{'Content-Type': 'application/json'}, | headers:{'Content-Type': 'application/json'}, | ||
body: JSON.stringify({ | body: JSON.stringify({ | ||
− | + | ApiKey:'<Private key>', | |
− | |||
FairId: '9df61f13-474b-442f-ac1f-edca7348ef71', //This value can be found in your url it's the value of f | FairId: '9df61f13-474b-442f-ac1f-edca7348ef71', //This value can be found in your url it's the value of f | ||
Body: { | Body: { | ||
Line 39: | Line 38: | ||
headers:{'Content-Type': 'application/json'}, | headers:{'Content-Type': 'application/json'}, | ||
body: JSON.stringify({ | body: JSON.stringify({ | ||
− | + | ApiKey:'<Private key>', | |
− | |||
FairId: '9df61f13-474b-442f-ac1f-edca7348ef71', //This value can be found in your url it's the value of f | FairId: '9df61f13-474b-442f-ac1f-edca7348ef71', //This value can be found in your url it's the value of f | ||
Body: { | Body: { |
Latest revision as of 15:01, 9 April 2024
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({
ApiKey:'<Private key>',
FairId: '9df61f13-474b-442f-ac1f-edca7348ef71', //This value can be found in your url it's the value of f
Body: {
Name: "Category Name",
NameShort: "Category Abbreviation",
Description: "", //optional
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,
DoNotShowInOnlineJudging: false, //optional
DoNotAllowTeams: false, //optional
MaxTeamSize: 3, //optional, by default there is no limit to the size of a team
EntryTypeId: 2, //optional, this value comes back from the info api call
}
})
})
.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({
ApiKey:'<Private key>',
FairId: '9df61f13-474b-442f-ac1f-edca7348ef71', //This value can be found in your url it's the value of f
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);});