Difference between revisions of "API Update Project"

From zFairs Contest Management
(Document update project payload and response)
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.
  
If you need to add a project see [[API Add Project]]
+
=== 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. Prefer this over username/password.
 +
|-
 +
| <code>Username</code> / <code>Password</code> || Yes* || Alternate auth if not using ApiKey.
 +
|-
 +
| <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.
 +
|}
  
 +
* Provide '''either''' <code>ApiKey</code> '''or''' <code>Username</code>+<code>Password</code>.
 +
 +
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({
 
             ApiKey:'<Private key>',
 
             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', // value of f in your URL
 
             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,
"CustomQuestions" : //optional
+
Approved: true,
[{
+
CustomQuestions: [{ Id: 55, Value: "small" }],
"Id": 123,
+
Files: [{
"Value": "This is my answer"
+
Base64String: "iVBORw0KGgo...",
},...]
+
FileName: "extra.png",
"Files": //optional
+
Caption: "Extra image"
[{  
+
}],
          "Base64String" : "iVBORw0KGgoAAAANSUhEUgAAAQIAA...", //not required if you use DownloadFromUrl
+
Participants: []  // optional; used mainly if attaching participant profile pictures
          "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 53: Line 68:
 
.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>
  
</syntaxhighlight>
 
  
== Where to get values ==
+
=== Field notes ===
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]]
+
* <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]].
  
You can also add '''FixedProjectId''', this allows you to upload the project Id you want to be used for your uploaded project.
 
  
 +
=== Related APIs ===
 +
* [[API Add Project]]
 +
* [[API Get Projects]]
 +
* [[API Upload Project Assets]]
 +
* [[API Set Project Id]]
  
  
<br/><br/><br/><br/>
+
<br/><br/>
 
[[Category: API]]
 
[[Category: API]]

Revision as of 12:49, 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. Prefer this over username/password.
Username / Password Yes* Alternate auth if not using ApiKey.
FairId Yes Fair GUID from the site URL (f query parameter).
Body Depends Request payload. Use {} when no body fields are needed.
  • Provide either ApiKey or Username+Password.

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