Upload a file attachment for an entity.
using System.Net.Http.Headers;var client = new HttpClient();var request = new HttpRequestMessage{ Method = HttpMethod.Post, RequestUri = new Uri("https://example.com/api/workspace/attachments"), Headers = { { "Authorization", "Bearer <token>" }, }, Content = new MultipartFormDataContent { new StringContent("") { Headers = { ContentType = new MediaTypeHeaderValue("application/octet-stream"), ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "File", FileName = "file", } } }, new StringContent("example") { Headers = { ContentType = new MediaTypeHeaderValue("text/plain"), ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "Description", } } }, new StringContent("example") { Headers = { ContentType = new MediaTypeHeaderValue("text/plain"), ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "OwnerResourceKind", } } }, new StringContent("example") { Headers = { ContentType = new MediaTypeHeaderValue("text/plain"), ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "OwnerModuleKey", } } }, new StringContent("example") { Headers = { ContentType = new MediaTypeHeaderValue("text/plain"), ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "OwnerContextResourceId", } } }, new StringContent("example") { Headers = { ContentType = new MediaTypeHeaderValue("text/plain"), ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "OwnerResourceObjectId", } } }, new StringContent("example") { Headers = { ContentType = new MediaTypeHeaderValue("text/plain"), ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "RelationsJson", } } }, new StringContent("2489E9AD-2EE2-8E00-8EC9-32D5F69181C0") { Headers = { ContentType = new MediaTypeHeaderValue("text/plain"), ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "OperationKey", } } }, },};using (var response = await client.SendAsync(request)){ response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body);}const url = 'https://example.com/api/workspace/attachments';const form = new FormData();form.append('File', 'file');form.append('Description', 'example');form.append('OwnerResourceKind', 'example');form.append('OwnerModuleKey', 'example');form.append('OwnerContextResourceId', 'example');form.append('OwnerResourceObjectId', 'example');form.append('RelationsJson', 'example');form.append('OperationKey', '2489E9AD-2EE2-8E00-8EC9-32D5F69181C0');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/api/workspace/attachments \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: multipart/form-data' \ --form File=@file \ --form Description=example \ --form OwnerResourceKind=example \ --form OwnerModuleKey=example \ --form OwnerContextResourceId=example \ --form OwnerResourceObjectId=example \ --form RelationsJson=example \ --form OperationKey=2489E9AD-2EE2-8E00-8EC9-32D5F69181C0Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”Optional access token for clients that cannot set Authorization headers. Prefer Authorization: Bearer <token> when possible.
Request Body
Section titled “Request Body”object
Responses
Section titled “Responses”Successful attachment result; shape depends on the resource owner.
object
object
object
object
object
object
object
object
Safe committed-mutation receipt of tag, comment and attachment mutations, returned when post-state data cannot be disclosed. Entity record and responsibility mutations answer Moltaro.Package.NET.Automation.EntityRecordMutationReceipt and Moltaro.Package.NET.Automation.EntityResponsibilityMutationReceipt instead.
object
Stable logical operation identifier.
Captured completion instant of the committed operation.
object
object
object
object
object
object
object
Stable audit correlation for the committed operation.
Whether the host returned an earlier durable result without another write.
object
object
object
object
object
Example
{ "Data": null, "Errors": [ { "Type": 0, "Severity": 0 } ], "Warnings": [ { "Type": 0, "Severity": 0 } ]}Bad Request
object
object
object
object
object
Example
{ "Data": null, "Errors": [ { "Type": 0, "Severity": 0 } ], "Warnings": [ { "Type": 0, "Severity": 0 } ]}Forbidden; the controller returns no response body.
Not Found
object
object
object
object
object
Example
{ "Data": null, "Errors": [ { "Type": 0, "Severity": 0 } ], "Warnings": [ { "Type": 0, "Severity": 0 } ]}The operation was refused; inspect Errors. Data may be null.
object
object
object
Safe committed-mutation receipt of tag, comment and attachment mutations, returned when post-state data cannot be disclosed. Entity record and responsibility mutations answer Moltaro.Package.NET.Automation.EntityRecordMutationReceipt and Moltaro.Package.NET.Automation.EntityResponsibilityMutationReceipt instead.
object
Stable logical operation identifier.
Captured completion instant of the committed operation.
object
object
object
object
object
object
object
Stable audit correlation for the committed operation.
Whether the host returned an earlier durable result without another write.
object
object
object
object
object
Example
{ "Data": null, "Errors": [ { "Type": 0, "Severity": 0 } ], "Warnings": [ { "Type": 0, "Severity": 0 } ]}Content Too Large
object
object
object
object
object
Example
{ "Data": null, "Errors": [ { "Type": 0, "Severity": 0 } ], "Warnings": [ { "Type": 0, "Severity": 0 } ]}