REST API - Add Attachment Request
10 min
api/v1/projects/{projectid}/artifacts/{artifactid}/attachments description adds a single file attachment to the specified artifact if the specified artifact is a document artifact, the file is uploaded as the document artifact file (not as an attachment in the utility panel url structure \[blueprint uri]/api/v1/projects/{projectid}/artifacts/{artifactid}/attachments projectid the id of the project containing the artifact you want to add the attachment to artifactid the id of the artifact you want to add the attachment to supported methods post docid\ hsi lzxs8g rx ydudzkg request body there are two ways to upload an attachment to add an attachment as a part of the request body, use the content md5 header and manually calculate a md5 token for the value instead of providing an attachment as a part of the request body, you have the option of adding different sets of data by using multipartcontent mime for multipartcontent, you must specify the content type header as multipart/form data (that is, content type multipart/form data;boundary={token} ) and use boundary parameters for more information on using multipartcontent, see http //www w3 org/protocols/rfc1341/7 2 multipart html http //www w3 org/protocols/rfc1341/7 2 multipart html for a reference in c#, see rest api using the content type multipart method docid 7wpvsza2qz1tianwjs7qn http status codes 200 ok 201 successfully created 206 partial content 400 bad request this error can occur for a variety of reasons at least one uri or request body parameter is invalid, such as one of the filter docid\ sv9gjverxczcgqdn28j7u , traces, offset or limit parameters a required value has not been provided if you are submitting a post docid\ hsi lzxs8g rx ydudzkg or patch docid\ rcjvhrlby6de zgkehxui request and have not added the x http method override parameter to your request header 401 unauthorized the blueprint token is missing, invalid or expired 403 forbidden the applicable permissions are needed for example, this error can occur when an author or collaborate license is needed for access comment permissions are needed on the artifact edit permissions are needed on the change summary job 404 notfound item is not found in the project for example, this error can occur when artifact not found artifact type not found project not found alm target not found change summary job not found user does not have edit permissions for this artifact, project or alm target 409 conflict reason for failure can be found in the response body additional information may also be found in the log 411 length required if the content length header is missing in the request 413 request entity too large if the provided file size is larger than allowed 415 unsupported media type if the provided media type is not of mime multipart content "form data " 416 request range not satisfiable if offset points to a part of a collection that is not available 500 internal server error 501 not implemented examples xml example request uri https //production blueprintcloud com/api/v1/projects/220870/artifacts/220914/attachments request header (using request body to add attachment) authorization blueprinttoken izrjb4xcd4ooyewt/3/bclvtz9tjrtwtvnxzljln6/j4jzp4tpeei4jcontent md5 86e8c9ef442ffe19f3f7502b9e11b5e4content disposition attachment;filename="bitmapattachment bmp"content type application/octet streamcontent length 9270 response body \<?xml version="1 0" ?>\<attachment xmlns\ i="http //www w3 org/2001/xmlschema instance" xmlns="http //www blueprintsys com/blueprint/api/v1"> \<filename>bitmapattachment png\</filename> \<id>51097\</id> \<link>http //localhost 61928/api/v1/projects/2080006/artifacts/2080014/attachments/51097\</link>\</attachment> json example request uri https //production blueprintcloud com/api/v1/projects/220870/artifacts/220914/attachments request header (using request body to add attachment) authorization blueprinttoken izrjb4xcd4ooyewt/3/bclvtz9tjrtwtvnxzljln6/j4jzp4tpeei4jcontent md5 86e8c9ef442ffe19f3f7502b9e11b5e4content disposition attachment;filename="bitmapattachment bmp"content type application/octet streamcontent length 9270 response body { "id" 51097, "filename" "bitmapattachment png", "link" "http //today/api/v1/projects/2080006/artifacts/2080014/attachments/51097"}