Difference between revisions of "API Upload Project Assets"

From zFairs Contest Management
(Document image and paperwork upload)
(Remove username/password API auth; ApiKey only)
 
Line 9: Line 9:
 
! Field !! Required !! Description
 
! Field !! Required !! Description
 
|-
 
|-
| <code>ApiKey</code> || Yes* || Private API key for your site. Prefer this over username/password.
+
| <code>ApiKey</code> || Yes || Private API key for your site.
|-
 
| <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>FairId</code> || Yes || Fair GUID from the site URL (<code>f</code> query parameter).
Line 18: Line 16:
 
|}
 
|}
  
* 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.
 
Calls must be run '''server-side''' — do not expose your API key in a browser.

Latest revision as of 12:55, 25 July 2026

Upload Project Assets

Upload project images/assets or paperwork files to an existing project.

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
}


Upload project image / asset

POST /api/data/project/file

fetch('/api/data/project/file', {
    method:'POST',
    headers:{'Content-Type': 'application/json'},
    body: JSON.stringify({
            ApiKey:'<Private key>',
            FairId: '9df61f13-474b-442f-ac1f-edca7348ef71',
            Body: {
				ProjectKey: "32161f13-474b-442f-ac1f-edca7348e000",
				Base64String: "iVBORw0KGgoAAAANSUhEUgAAAQIAA...", // not required if DownloadFromUrl is set
				DownloadFromUrl: "https://yoursite.com/somefile.png", // optional alternative to 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

Same endpoint. Paperwork should be PDF. Set PaperworkFileType from API Get InfoPaperworkFileTypes.

fetch('/api/data/project/file', {
    method:'POST',
    headers:{'Content-Type': 'application/json'},
    body: JSON.stringify({
            ApiKey:'<Private key>',
            FairId: '9df61f13-474b-442f-ac1f-edca7348ef71',
            Body: {
				ProjectKey: "32161f13-474b-442f-ac1f-edca7348e000",
				PaperworkFileType: 123,
				Base64String: "JVBERi0xLjQK...",
				DownloadFromUrl: null,
				FileName: "form1c.pdf",
				Caption: "Form 1C"
			}
        })
})
.then(response => response.json())
.then(data=>{console.log('Success: ',data);})
.catch((error)=>{console.log('Error: ', error);});

Response

{
  Success: true,
  Message: null,
  Body: { ProjectKey: "...", FileName: "myAwesomeFile.png", ... }
}

If the project key is invalid:

{ Success: false, Message: "Project not found with ProjectKey: ..." }

Field notes

  • Provide either Base64String or DownloadFromUrl.
  • When PaperworkFileType > 0, the file is stored as paperwork; otherwise as a project asset/image.
  • Uploaded files appear on API Get Projects under projectFiles / paperworkFiles with a /file/showfile/{publicId} path.

Related APIs