---
title: "Attachment"
description: "How to POST an Attachment via Visma Net API in C#? Please read more about the attachment-specific endpoints at Documentation/Swagger WebClient Class public void…"
lang: en
languages:
  en: https://docs.vismasoftware.no/vismanetapi/how-tos/attachment/index.md
lastmod: 2026-02-18
---

> Documentation index: https://docs.vismasoftware.no/vismanetapi/how-tos/attachment/llms.txt


# Attachment

Last modified February 18, 2026

> How to POST an Attachment via Visma Net API in C#? Please read more about the attachment-specific endpoints at Documentation/Swagger WebClient Class public void…


## How to POST an Attachment via Visma Net API in C#?

> [!Note]
> Please read more about the attachment-specific endpoints at [Documentation/Swagger](https://docs.vismasoftware.no/vismanetapi/index.md#documentationswagger)

### WebClient Class

```csharp
public void postAttachment(string[] files, string <objectID>, string token, string companyId)
{
    using (WebClient client = new WebClient())
    {
        client.Headers.Add("ipp-company-id", "<companyId>");
        client.Headers.Add("ipp-application-type", "Visma.net Financials");
        client.Headers.Add("Authorization", "bearer<token>");
        
        for (int i = 0; i < files.Length; i++) // Multiple
        {
            byte[] responseArray = client.UploadFile(
                @"https://api.finance.visma.net/v1/<Endpoint>/<objectID>/Attachment", 
                "POST", 
                files[i]
            );
        }
    }
}
```

### HttpClient Class

```csharp
 public void postAttachmentHttpClient()
        {
                using (var client = new HttpClient())
                {
 
                    client.DefaultRequestHeaders.Add("ipp-application-type", "Visma.net Financials");
                    client.DefaultRequestHeaders.Add("ipp-company-id", "<companyID>");
                    client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>");

                    HttpResponseMessage response;
                    var content = new MultipartFormDataContent();

                    var path = Path.Combine(@"<path>");
                    string fileName = Path.GetFileName(path);

                    FileStream fs = File.OpenRead(path);
                    var sc = new StreamContent(fs);

                    sc.Headers.Add("Content-Type", "application/octet-stream");
                    sc.Headers.Add("Content-Disposition","form-data; name=\"file\"; filename=\"" + Path.GetFileName(path) + "\"");
                    
                    content.Add(sc, "file", fileName);
                    response = client.PostAsync(@"https://api.finance.visma.net/v1/<endpoint>/<objectID>/Attachment", content).Result;
                }
            }
```

> [!Important]
> The sample code is provided “AS IS” and any express or implied warranties, including the implied warranties of merchantability and fitness for a particular purpose, are disclaimed. In no event shall Visma or contributors be liable for any direct, indirect, incidental, special, exemplary or consequential damages.

## How to fetch attachment

**Step 1.** Fetch the attachmentid from the document, for example

GET <https://api.finance.visma.net/v1/supplierInvoice/900002>

![GetInvoice](https://docs.vismasoftware.no/vismanetapi/how-tos/attachment/getInvoice.png)

**Step 2.** Fetch the Base64 using the attachmentid from step one in the attachment endpoint. For example:
GET <https://api.finance.visma.net/v1/attachment/7319362a-126f-47ca-8bce-669c814b0576>

![GetAttachment](https://docs.vismasoftware.no/vismanetapi/how-tos/attachment/getAttachment.png)

**Step 3.**
Once you have fetched the Base64, you should be able to decode it to a file

---

[View this page](https://docs.vismasoftware.no/vismanetapi/how-tos/attachment/)


## In this section

