Forum

Upload attachment f...
 
Notifications
Retirer tout

Upload attachment file using API

2 Posts
2 Utilisateurs
0 Reactions
438 Vu
Sylvain Devidal
(@magicbuzz)
Posts: 38
Trusted Member
Début du sujet
 
[#9999]

Hello,

I'm using the REST API to create tickets from a custom tool, and it works fine.

Now I want to add some files (logs, configuratuon files, etc.) to the created tickets.

I tried using this query :

{ "refType": "Ticket", "refId": "1234", "description": "Fichiers du mobile", "fileName": "bupreport.zip", "file": "{Convert.ToBase64String(zip)}" }

It creates an attachment, but I can't see the file, it looks like it wasn't uploaded.
I'm not sure how I should provide the file contents.
I tried encoding the file in base64 in a field "file" but it looks like to be ignored.

I tried as a multipart request too, but it fails.

var content = new MultipartFormDataContent();
content.Add(new StringContent("Ticket"), "refType");
content.Add(new StringContent(ticket.Id.ToString()), "refId");
content.Add(new StringContent("BugReport"), "description");
content.Add(new StringContent("bupreport.zip"), "fileName");
content.Add(byteArrayContent, "data", "bugreport.zip");

How can I do ?

If it's impossible, how can I upload an attachment using a regular HTTP POST request like the browser uses when we send a file from the HTML GUI?


 
Posté : 04/12/2025 5:59 pm
(@babynus)
Posts: 14952
Membre Admin
 

The API is not designed to upload files.


 
Posté : 12/12/2025 5:49 pm
Share:
Retour en haut