So I managed to use the the REST API to create and update tickets with some problems in the beginning but now its working fine.
Now I just wanted to add an attachment to an exisiting ticket and here I got an error message which not really gets me anywhere:
no value sent for required parameter ‘changes’
Stack:
[/opt/rt4/share/html/REST/1.0/dhandler:285]
[/opt/rt4/share/html/REST/1.0/autohandler:54]
[/opt/rt4/sbin/…/lib/RT/Interface/Web.pm:681]
[/opt/rt4/sbin/…/lib/RT/Interface/Web.pm:369]
[/opt/rt4/share/html/autohandler:53]
and my code:
public string RT_REST_POST_Attachment(string request, string TicketID,IFormFile file)
{
string result = "";
var RT_URL = configuration.GetValue<string>("RT_Config:URL");
if (GlobalVariables.RT_Cookie == null)
{
GlobalVariables.RT_Cookie = new CookieContainer();
RT_Login();
}
using (var handler = new HttpClientHandler { CookieContainer = GlobalVariables.RT_Cookie })
using (var client = new HttpClient(handler))
{
using (var formData = new MultipartFormDataContent())
{
formData.Add(new StringContent("id: "+TicketID+ Environment.NewLine+" Action: comment" + Environment.NewLine +" Attachment: "+file.FileName+ Environment.NewLine+" Text: Attachment added"), "content");
formData.Add(new StreamContent(file.OpenReadStream()), "attachment_1");
client.DefaultRequestHeaders.Add("Referer", RT_URL);
result = client.PostAsync(RT_URL + "/REST/1.0/" + request, formData).Result.Content.ReadAsStringAsync().Result;
}
}
return result;
}
Any help tips or tricks are highly appreciated.
Regards Martin