> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://developer.projectmanager.com/api-reference/risk-file/upload-risk-file/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developer.projectmanager.com/_mcp/server. # Upload Risk File POST https://api.projectmanager.com/api/data/risks/{riskId}/files Content-Type: multipart/form-data Uploads a file to a risk. ProjectManager allows you to store Files connected to other elements of your Workspace such as a Project, a Task, or Home. Files are maintained separately based on the location where the file was stored. When you upload a File, please allow a few moments for the File to be processed and verified. ProjectManager may reject File uploads that contain problems such as malware. Once a File has completed the upload the process, you may retrieve it using the DownloadFile API. This API returns a JSON response indicating success or failure. Reference: https://developer.projectmanager.com/api-reference/risk-file/upload-risk-file ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Request ### Path parameters - `riskId` (string, required) — The reference to the risk ### Headers - `x-integration-name` (string, optional) — The name of the calling system passed along as a header parameter ### Body (multipart/form-data) This endpoint expects a multipart form containing an optional file. - `file` (file, optional) ## Response ### 200 Success - `error` (AstroError, optional, nullable) — If the API call failed, this will contain information about the error that occurred. - `success` (boolean, optional) — True if the API call succeeded; false otherwise. - `hasError` (boolean, optional) — True if the API call failed. - `statusCode` (enum, optional) — The HTTP code of the response. - Allowed values: `Continue`, `SwitchingProtocols`, `Processing`, `EarlyHints`, `OK`, `Created`, `Accepted`, `NonAuthoritativeInformation`, `NoContent`, `ResetContent`, `PartialContent`, `MultiStatus`, `AlreadyReported`, `IMUsed`, `MultipleChoices`, `MovedPermanently`, `Found`, `SeeOther`, `NotModified`, `UseProxy`, `Unused`, `TemporaryRedirect`, `PermanentRedirect`, `BadRequest`, `Unauthorized`, `PaymentRequired`, `Forbidden`, `NotFound`, `MethodNotAllowed`, `NotAcceptable`, `ProxyAuthenticationRequired`, `RequestTimeout`, `Conflict`, `Gone`, `LengthRequired`, `PreconditionFailed`, `RequestEntityTooLarge`, `RequestUriTooLong`, `UnsupportedMediaType`, `RequestedRangeNotSatisfiable`, `ExpectationFailed`, `MisdirectedRequest`, `UnprocessableEntity`, `Locked`, `FailedDependency`, `UpgradeRequired`, `PreconditionRequired`, `TooManyRequests`, `RequestHeaderFieldsTooLarge`, `UnavailableForLegalReasons`, `InternalServerError`, `NotImplemented`, `BadGateway`, `ServiceUnavailable`, `GatewayTimeout`, `HttpVersionNotSupported`, `VariantAlsoNegotiates`, `InsufficientStorage`, `LoopDetected`, `NotExtended`, `NetworkAuthenticationRequired` - `data` (FileDto, optional) — Represents a file in project manager ## Types ### AstroError Information about an error that occurred within the ProjectManager API. - `technicalError` (string, optional, nullable) — A technical description of the error that occurred. Not suitable for display to end users. - `additionalErrors` (list of string, optional, nullable) — If additional errors beyond the main error in `Message` occurred, they will be listed here as individual messages. - `validationErrors` (map from string to list of string, optional, nullable) — This contains a dictionary of validation errors. The key is the name of the field - `message` (string, optional, nullable) — A description of the error that occurred. If your application has a user interface, show this message to explain what went wrong. ### FileDto Represents a file in project manager - `id` (string, optional) — The identifier for this file - `projectId` (string, optional, nullable) — If specified this file belongs to a project. The value is the id of this project - `taskId` (string, optional, nullable) — If specified, the file has been associated with this task. - `ownerId` (string, optional) — The reference for who uploaded the file - `createdDate` (string, optional) — The UTC time the file was created. - `folderId` (string, optional) — A reference to the folder - `fileType` (string, optional) — The type of the file - `fileTypeLabel` (string, optional) — A user friendly label for the file type - `size` (integer, optional) — Size of the file in bytes - `downloadPath` (string, optional) — Path to download the file - `deleted` (boolean, optional) — Is the file in the trash can - `type` (string, optional) — Defines the object type the file belongs to. - `name` (string, optional) — The name of the file - `entityOwnerId` (string, optional) — Id of owner of parent entity ## Examples **Request** ```json { "file": "" } ``` **Response** ```json { "error": { "technicalError": "string", "additionalErrors": [ "string" ], "validationErrors": {}, "message": "string" }, "success": true, "hasError": true, "statusCode": "Continue", "data": { "id": "string", "projectId": "string", "taskId": "string", "ownerId": "string", "createdDate": "2024-01-15T09:30:00Z", "folderId": "string", "fileType": "string", "fileTypeLabel": "string", "size": 1, "downloadPath": "string", "deleted": true, "type": "string", "name": "string", "entityOwnerId": "string" } } ``` **SDK Code** ```python import requests url = "https://api.projectmanager.com/api/data/risks/riskId/files" files = { "file": "open('[object Object]', 'rb')" } headers = {"Authorization": "Bearer "} response = requests.post(url, files=files, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.projectmanager.com/api/data/risks/riskId/files'; const form = new FormData(); form.append('file', '[object Object]'); const options = {method: 'POST', headers: {Authorization: 'Bearer '}}; options.body = form; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.projectmanager.com/api/data/risks/riskId/files" payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.projectmanager.com/api/data/risks/riskId/files") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.projectmanager.com/api/data/risks/riskId/files") .header("Authorization", "Bearer ") .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n") .asString(); ``` ```php request('POST', 'https://api.projectmanager.com/api/data/risks/riskId/files', [ 'multipart' => [ [ 'name' => 'file', 'filename' => '[object Object]', 'contents' => null ] ] 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.projectmanager.com/api/data/risks/riskId/files"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer "); request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"[object Object]\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Authorization": "Bearer "] let parameters = [ [ "name": "file", "fileName": "[object Object]" ] ] let boundary = "---011000010111000001101001" var body = "" var error: NSError? = nil for param in parameters { let paramName = param["name"]! body += "--\(boundary)\r\n" body += "Content-Disposition:form-data; name=\"\(paramName)\"" if let filename = param["fileName"] { let contentType = param["content-type"]! let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8) if (error != nil) { print(error as Any) } body += "; filename=\"\(filename)\"\r\n" body += "Content-Type: \(contentType)\r\n\r\n" body += fileContent } else if let paramValue = param["value"] { body += "\r\n\r\n\(paramValue)" } } let request = NSMutableURLRequest(url: NSURL(string: "https://api.projectmanager.com/api/data/risks/riskId/files")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```