Difference between revisions of "API Update Project"
From zFairs Contest Management
(Remove username/password API auth; ApiKey only) |
|||
| (4 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
| − | == Update Project== | + | == Update Project == |
| − | + | 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({ | ||
| − | + | ApiKey:'<Private key>', | |
| − | + | FairId: '9df61f13-474b-442f-ac1f-edca7348ef71', // value of f in your URL | |
| − | FairId: '9df61f13-474b-442f-ac1f-edca7348ef71', // | ||
Body: { | Body: { | ||
| − | + | ProjectKey: "32161f13-474b-442f-ac1f-edca7348e000", // required | |
| − | ,CategoryId: 123 | + | 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 | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
} | } | ||
}) | }) | ||
| Line 53: | 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]]. | ||
| + | |||
| − | + | === Related APIs === | |
| + | * [[API Add Project]] | ||
| + | * [[API Get Projects]] | ||
| + | * [[API Upload Project Assets]] | ||
| + | * [[API Set Project Id]] | ||
| − | |||
| − | |||
| − | + | <br/><br/> | |
| + | [[Category: API]] | ||
Latest revision as of 12:55, 25 July 2026
Contents
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
ProjectKeyis 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