Difference between revisions of "API Update Project"

From zFairs Contest Management
(Created page with "== Update Project== You can use our api to update a project to do this you need to POST a message to your site. Below is an example of what needs to be posted. <syntaxhighlig...")
 
(Remove username/password API auth; ApiKey only)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Update Project==
+
== Update Project ==
You can use our api to update a project to do this you need to POST a message to your site. Below is an example of what needs to be posted.
+
Updates an existing project identified by <code>ProjectKey</code>. Can update core fields, custom questions, and attach additional files.
  
 +
=== Authentication ===
 +
All data API calls are <code>POST</code> (unless noted) with JSON body:
 +
 +
{| class="wikitable"
 +
|-
 +
! Field !! Required !! Description
 +
|-
 +
| <code>ApiKey</code> || Yes || Private API key for your site.
 +
|-
 +
| <code>FairId</code> || Yes || Fair GUID from the site URL (<code>f</code> query parameter).
 +
|-
 +
| <code>Body</code> || Depends || Request payload. Use <code>{}</code> when no body fields are needed.
 +
|}
 +
 +
 +
Calls must be run '''server-side''' — do not expose your API key in a browser.
 +
 +
=== Response envelope ===
 +
Most endpoints return:
 +
 +
<pre>
 +
{
 +
  Success: true,
 +
  Message: null,  // error text when Success is false
 +
  Body: { ... }    // endpoint-specific payload
 +
}
 +
</pre>
 +
 +
 +
=== Request ===
 
<syntaxhighlight lang="JavaScript" line>
 
<syntaxhighlight lang="JavaScript" line>
 
+
fetch('/api/data/project/update', {
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', // value of f in your URL
             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
+
ProjectKey: "32161f13-474b-442f-ac1f-edca7348e000", // required
,CategoryId: 123 //Required
+
Title: "Updated Title",
,SubCategoryId: 123 //optional
+
CategoryId: 123,
,Plan: 'Project Plan' // optional
+
SubCategoryId: 456,
,Abstract: 'Project Abstract'// optional
+
Plan: "Updated plan",
,Description: 'Project Description'// optional
+
Abstract: "Updated abstract",
,ProjectKey: ’36 char GUID’
+
Description: "Updated description",
,EntryVideoLink: ‘video Link’ //optional
+
EntryVideoLink: "https://...",
,EntryVideoLink2: ‘video Link’ //optional
+
EntryVideoLink2: "https://...",
,CategoryAwardId: 1 // optional
+
FixedProjectId: "AB-100",
,SpecialAwardsIds: [1, 2] //optional
+
EntryTypeId: 2,
"Files": [{ //optional
+
Approved: true,
          "Base64String" : "iVBORw0KGgoAAAANSUhEUgAAAQIAA...", //not required if you use DownloadFromUrl
+
CustomQuestions: [{ Id: 55, Value: "small" }],
          "DownloadFromUrl":"http://yoursite.com/somefile.png",//optional can be used in stead of Base64String
+
Files: [{
          "FileName": "myAwesomeFile.png",
+
Base64String: "iVBORw0KGgo...",
          "Caption": "indescribable"
+
FileName: "extra.png",
          },
+
Caption: "Extra image"
          {
+
}],
          "Base64String" : "iVBORw0KGgoAAAANSUhEUgAAAQIAA...",
+
Participants: []  // optional; used mainly if attaching participant profile pictures
          "FileName": "myAwesomeFile2.png",
 
          "Caption": "indescribable also"
 
          },
 
          {
 
          "DownloadFromUrl":"http://yoursite.com/somefile.png",
 
          "FileName": "myAwesomething.pdf",
 
          "Caption": "indescribable pdf"
 
          }]
 
 
}
 
}
 
         })
 
         })
Line 45: Line 65:
 
.then(data=>{console.log('Success: ',data);})
 
.then(data=>{console.log('Success: ',data);})
 
.catch((error)=>{console.log('Error: ', error);});
 
.catch((error)=>{console.log('Error: ', error);});
 +
</syntaxhighlight>
 +
 +
=== Response ===
 +
On success returns the request body with <code>ProjectId</code>/<code>ProjectKey</code> filled, and optional <code>InterviewRoomUrl</code>.
 +
 +
<pre>
 +
{
 +
  Success: true,
 +
  Message: null,
 +
  Body: { ProjectKey: "...", ProjectId: "AB-100", Title: "Updated Title", ... }
 +
}
 +
</pre>
 +
 +
If the project is missing or not in the fair:
 +
 +
<pre>
 +
{ Success: false, Message: "Project not found" }
 +
</pre>
 +
 +
 +
=== Field notes ===
 +
* <code>ProjectKey</code> is required.
 +
* This endpoint does not re-register participants the way [[API Add Project]] does; focus is project metadata and files.
 +
* For display project id batch updates, see [[API Set Project Id]].
  
</syntaxhighlight>
 
  
== Where to get values ==
+
=== Related APIs ===
Various fields need id values such as '''CategoryId''', '''CategoryAwardId''', and '''SpecialAwardIds'''. You can get these values from our API. Check out [[API Get Info]]
+
* [[API Add Project]]
 +
* [[API Get Projects]]
 +
* [[API Upload Project Assets]]
 +
* [[API Set Project Id]]
  
=== Additional Optional fields of Participants ===
 
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.
+
<br/><br/>
 +
[[Category: API]]

Latest revision as of 12:55, 25 July 2026

Update Project

Updates an existing project identified by ProjectKey. Can update core fields, custom questions, and attach additional files.

Authentication

All data API calls are POST (unless noted) with JSON body:

Field Required Description
ApiKey Yes Private API key for your site.
FairId Yes Fair GUID from the site URL (f query parameter).
Body Depends Request payload. Use {} when no body fields are needed.


Calls must be run server-side — do not expose your API key in a browser.

Response envelope

Most endpoints return:

{
  Success: true,
  Message: null,   // error text when Success is false
  Body: { ... }    // endpoint-specific payload
}


Request

fetch('/api/data/project/update', {
    method:'POST',
    headers:{'Content-Type': 'application/json'},
    body: JSON.stringify({
            ApiKey:'<Private key>',
            FairId: '9df61f13-474b-442f-ac1f-edca7348ef71', // value of f in your URL
            Body: {
				ProjectKey: "32161f13-474b-442f-ac1f-edca7348e000", // required
				Title: "Updated Title",
				CategoryId: 123,
				SubCategoryId: 456,
				Plan: "Updated plan",
				Abstract: "Updated abstract",
				Description: "Updated description",
				EntryVideoLink: "https://...",
				EntryVideoLink2: "https://...",
				FixedProjectId: "AB-100",
				EntryTypeId: 2,
				Approved: true,
				CustomQuestions: [{ Id: 55, Value: "small" }],
				Files: [{
					Base64String: "iVBORw0KGgo...",
					FileName: "extra.png",
					Caption: "Extra image"
				}],
				Participants: []  // optional; used mainly if attaching participant profile pictures
			}
        })
})
.then(response => response.json())
.then(data=>{console.log('Success: ',data);})
.catch((error)=>{console.log('Error: ', error);});

Response

On success returns the request body with ProjectId/ProjectKey filled, and optional InterviewRoomUrl.

{
  Success: true,
  Message: null,
  Body: { ProjectKey: "...", ProjectId: "AB-100", Title: "Updated Title", ... }
}

If the project is missing or not in the fair:

{ Success: false, Message: "Project not found" }


Field notes

  • ProjectKey is required.
  • This endpoint does not re-register participants the way API Add Project does; focus is project metadata and files.
  • For display project id batch updates, see API Set Project Id.


Related APIs