Difference between revisions of "API Add Project"

From zFairs Contest Management
(Created page with "== Add Project== You can use our api to add a project and it's participants To do this you need to POST a message to your site. Below is an example of what needs to be posted....")
 
 
(23 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
== Add Project==
 
== Add Project==
 
You can use our api to add a project and it's participants 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 a project and it's participants To do this you need to POST a message to your site. Below is an example of what needs to be posted.
 +
 +
If you only want to update a project see [[API Update Project]]
  
 
<syntaxhighlight lang="JavaScript" line>
 
<syntaxhighlight lang="JavaScript" line>
  
fetch('/api/data/person', {
+
fetch('/api/data/project', {
 
     method:'POST',
 
     method:'POST',
 
     headers:{'Content-Type': 'application/json'},
 
     headers:{'Content-Type': 'application/json'},
 
     body: JSON.stringify({
 
     body: JSON.stringify({
             Username:'admin username',
+
             ApiKey:'<Private key>',
            Password: 'password',
 
 
             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: {
 
Title:'Project Title' //Required
 
Title:'Project Title' //Required
,CategoryId  //Required
+
,CategoryId: 123 //Required
,Plan: 'Project Plan'
+
,SubCategoryId: 123 //optional
,Abstract: 'Project Abstract'
+
,Plan: 'Project Plan' // optional
,Description: 'Project Description'
+
,Abstract: 'Project Abstract'// optional
 +
,Description: 'Project Description'// optional
 +
,ProjectKey: ’36 char GUID’//optional
 +
,EntryVideoLink: ‘video Link’ //optional
 +
,EntryVideoLink2: ‘video Link’ //optional
 +
,CategoryAwardId: 1 // optional
 +
,SpecialAwardsIds: [1, 2] //optional
 +
,EntryTypeId: 2 //optional value come from info api
 +
,Language:'Spanish' //optional - interpreter need for this language
 +
,InPerson:'Yes' //optional - 'yes' or 'no'
 
,Participants : [{
 
,Participants : [{
 
FirstName: 'Jane' //Required
 
FirstName: 'Jane' //Required
 
,LastName: 'Doe' //Required
 
,LastName: 'Doe' //Required
 
,Grade: 6 //Required
 
,Grade: 6 //Required
,TeacherId: '' //Required
+
,TeacherId: '9df61f13-474b-442f-ac1f-edca7348ef71' //Required
 
,SchoolId: 24 //Required
 
,SchoolId: 24 //Required
 
,Email: 'jane@example.com'
 
,Email: 'jane@example.com'
Line 33: Line 43:
 
,Zip: '65951'
 
,Zip: '65951'
 
,Role: 'Student'  
 
,Role: 'Student'  
}]
+
                                        ,ID:  'Student GUID ID' //optional
 +
                                        ,Username: 'Student User Name' //optional
 +
                                        ,Password:  'Student Password' //optional
 +
,Language:'Spanish' //optional - interpreter need for this language
 +
,ProfilePicture: { //Optional
 +
Base64String: 'base64 file string',
 +
"FileName": "myAwesomeFileDude.png",
 +
"Caption": "indescribable profile Pic"
 +
}
 +
 
 +
}],
 +
"CustomQuestions" : //optional
 +
[{
 +
"Id": 123,
 +
"Value": "This is my answer"
 +
},...]
 +
"Files": //optional
 +
[{
 +
          "Base64String" : "iVBORw0KGgoAAAANSUhEUgAAAQIAA...", //not required if you use DownloadFromUrl
 +
          "DownloadFromUrl":"http://yoursite.com/somefile.png",//optional can be used in stead of Base64String
 +
          "FileName": "myAwesomeFile.png",
 +
          "Caption": "indescribable"
 +
          },
 +
          {
 +
          "Base64String" : "iVBORw0KGgoAAAANSUhEUgAAAQIAA...",
 +
          "FileName": "myAwesomeFile2.png",
 +
          "Caption": "indescribable also"
 +
          },
 +
          {
 +
          "DownloadFromUrl":"http://yoursite.com/somefile.png",
 +
          "FileName": "myAwesomething.pdf",
 +
          "Caption": "indescribable pdf"
 +
          }]
 
}
 
}
 
         })
 
         })
Line 42: Line 84:
  
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
== Where to get values ==
 +
Various fields need id values such as '''CategoryId''', '''CustomQuestion Ids''', '''CategoryAwardId''', and '''SpecialAwardIds'''. You can get these values from our API. Check out [[API Get Info]]
 +
 +
A participant record is very similar to a teacher record see [[API Add Person]] for optional fields of participants.
 +
 +
 +
You can also add '''FixedProjectId''', this allows you to upload the project Id you want to be used for your uploaded project.
  
  
=== Additional Optional fields of Participants ===
 
All of these fields would be part of the body.
 
  
* '''Username''' (string max length 25)
+
<br/><br/><br/><br/>
**If this username is not available one will be assigned
+
[[Category: API]]
* '''Password''' (string max length 25)
 
* '''HighestLevelOfEducation'''
 
**Less Than HS Graduate
 
**High School Diploma or Equivalent
 
**Some College
 
**Technical School
 
**2-Year College Degree
 
**4-Year College Degree
 
**Some Graduate School
 
**Master's Level Degree
 
**Doctorate (Academic)
 
**Doctorate (Professional)
 
**Not Indicated
 
*'''JobTitle'''
 
*'''Employer'''
 
*'''JudgesPreferences''' (object)
 
**this is an object, which can be added to body. like JudgesPreferences: { /* add the following optional parameters below */}
 
**you need to provide the category id's in the category1-3
 
**you need to provide judging Session id's for judgingSessions array
 
**See [[API_Get_Info]] to get these id's
 
***'''Category1''' (int)
 
***'''Category2''' (int)
 
***'''Category3''' (int)
 
***'''PreviouslyJudged''' (boolean true/false)
 
***'''JudgingSessions''' (int array)
 
****Not provided will not update sessions, empty array will clear out sessions for that judge.
 
****example [] or [1,2,...]
 

Latest revision as of 20:48, 10 April 2024

Add Project

You can use our api to add a project and it's participants To do this you need to POST a message to your site. Below is an example of what needs to be posted.

If you only want to update a project see API Update Project

fetch('/api/data/project', {
    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: {
				Title:'Project Title' //Required
				,CategoryId: 123  //Required
				,SubCategoryId: 123 //optional
				,Plan: 'Project Plan' // optional
				,Abstract: 'Project Abstract'// optional
				,Description: 'Project Description'// optional
				,ProjectKey: ’36 char GUID’//optional
				,EntryVideoLink: ‘video Link’ //optional
				,EntryVideoLink2: ‘video Link’ //optional
				,CategoryAwardId: 1 // optional
				,SpecialAwardsIds: [1, 2] //optional
				,EntryTypeId: 2 //optional value come from info api
				,Language:'Spanish' //optional - interpreter need for this language
				,InPerson:'Yes' //optional - 'yes' or 'no'
				,Participants : [{
					FirstName: 'Jane' //Required
					,LastName: 'Doe' //Required
					,Grade: 6 //Required
					,TeacherId: '9df61f13-474b-442f-ac1f-edca7348ef71' //Required
					,SchoolId: 24 //Required
					,Email: 'jane@example.com'
					,Email1: 'Doe@example.com'
					,Phone: '800-000-0000'
					,Phone1: '800-123-1324'
					,Address: '1219 45th st'
					,Address2: 'APT 3B'
					,City: 'Ogden'
					,State: 'VA'
					,Zip: '65951'
					,Role: 'Student' 
                                        ,ID:  'Student GUID ID' //optional
                                        ,Username: 'Student User Name' //optional
                                        ,Password:  'Student Password' //optional
					,Language:'Spanish' //optional - interpreter need for this language
					,ProfilePicture: { //Optional
						Base64String: 'base64 file string',
						"FileName": "myAwesomeFileDude.png",
						"Caption": "indescribable profile Pic"
					}

				}],
				"CustomQuestions" : //optional
					[{
						"Id": 123,
						"Value": "This is my answer"
					},...] 
				"Files": //optional
					[{ 
           					"Base64String" : "iVBORw0KGgoAAAANSUhEUgAAAQIAA...", //not required if you use DownloadFromUrl
           					"DownloadFromUrl":"http://yoursite.com/somefile.png",//optional can be used in stead of Base64String
         	  				"FileName": "myAwesomeFile.png",
           					"Caption": "indescribable"
           					},
           					{
           					"Base64String" : "iVBORw0KGgoAAAANSUhEUgAAAQIAA...",
           					"FileName": "myAwesomeFile2.png",
    		       				"Caption": "indescribable also"
           					},
           					{
           					"DownloadFromUrl":"http://yoursite.com/somefile.png",
           					"FileName": "myAwesomething.pdf",
           					"Caption": "indescribable pdf"
           				}]
			}
        })
})
.then(response => response.json())
.then(data=>{console.log('Success: ',data);})
.catch((error)=>{console.log('Error: ', error);});

Where to get values

Various fields need id values such as CategoryId, CustomQuestion Ids, CategoryAwardId, and SpecialAwardIds. You can get these values from our API. Check out API Get Info

A participant record is very similar to a teacher record see API Add Person for optional fields of participants.


You can also add FixedProjectId, this allows you to upload the project Id you want to be used for your uploaded project.