Difference between revisions of "API Upload Project Assets"
From zFairs Contest Management
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | == Upload Project Image == | + | == Upload Project Assets == |
− | You can use our | + | |
+ | === Upload Project Image === | ||
+ | You can use our API to upload images to a project, so these can be viewed by your judges or in the showcase. 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/project/file', { | ||
+ | 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: { | ||
+ | "ProjectKey":"32161f13-474b-442f-ac1f-edca7348e000", | ||
+ | "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" | ||
+ | } | ||
+ | }) | ||
+ | }) | ||
+ | .then(response => response.json()) | ||
+ | .then(data=>{console.log('Success: ',data);}) | ||
+ | .catch((error)=>{console.log('Error: ', error);}); | ||
+ | |||
+ | </syntaxhighlight> | ||
+ | |||
+ | === Upload Project Paperwork === | ||
+ | You can use our API to upload project paperwork, so these can be viewed by your judges, SRC, and IRB. These files need to be PDFs. You will need to get the PaperworkFileType form the [[API Get Info]]. 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> | <syntaxhighlight lang="JavaScript" line> | ||
Line 13: | Line 41: | ||
Body: { | Body: { | ||
"ProjectKey":"32161f13-474b-442f-ac1f-edca7348e000", | "ProjectKey":"32161f13-474b-442f-ac1f-edca7348e000", | ||
+ | "PaperworkFileType": 123, // this is pulled from the get info api | ||
"Base64String" : "iVBORw0KGgoAAAANSUhEUgAAAQIAA...", //not required if you use DownloadFromUrl | "Base64String" : "iVBORw0KGgoAAAANSUhEUgAAAQIAA...", //not required if you use DownloadFromUrl | ||
"DownloadFromUrl":"http://yoursite.com/somefile.png", //optional can be used in stead of Base64String | "DownloadFromUrl":"http://yoursite.com/somefile.png", //optional can be used in stead of Base64String | ||
− | "FileName": "myAwesomeFile.png | + | "FileName": "myAwesomeFile.png" |
− | |||
} | } | ||
}) | }) | ||
Line 25: | Line 53: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | |||
+ | <br/><br/><br/><br/> | ||
+ | [[Category: API]] |
Latest revision as of 20:58, 10 April 2024
Upload Project Assets
Upload Project Image
You can use our API to upload images to a project, so these can be viewed by your judges or in the showcase. 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/project/file', {
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: {
"ProjectKey":"32161f13-474b-442f-ac1f-edca7348e000",
"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"
}
})
})
.then(response => response.json())
.then(data=>{console.log('Success: ',data);})
.catch((error)=>{console.log('Error: ', error);});
Upload Project Paperwork
You can use our API to upload project paperwork, so these can be viewed by your judges, SRC, and IRB. These files need to be PDFs. You will need to get the PaperworkFileType form the API Get Info. 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/project/file', {
method:'POST',
headers:{'Content-Type': 'application/json'},
body: JSON.stringify({
Username:'admin username',
Password: 'password',
FairId: '9df61f13-474b-442f-ac1f-edca7348ef71', //This value can be found in your url it's the value of f
Body: {
"ProjectKey":"32161f13-474b-442f-ac1f-edca7348e000",
"PaperworkFileType": 123, // this is pulled from the get info api
"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"
}
})
})
.then(response => response.json())
.then(data=>{console.log('Success: ',data);})
.catch((error)=>{console.log('Error: ', error);});