Hallo everybody,
I added a folder to a system through an API call, now I also have to add a file to this folder.
class Program
{
static void Main(string[] args)
{
var client = new RestClient("http://172.18.xxxxxx");
client.Authenticator = new HttpBasicAuthenticator("xxxxxxxxxxxxx", "xxxx");
client.Timeout = -1;
var request = new RestRequest("/osrest/api/documents/insert", Method.POST);
request.AddHeader("content-type", "multipart/form-data");
request.AlwaysMultipartFormData = true;
request.AddParameter("Object", "{\"cabinet\": \"Posteingang\",\"name\": \"Posteingang\",\"objectTypeId\":" + " \"2\",\"fields\": {\"Eingangsdatum\": {\"value\": \"21.12.2020\"}}}");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
therefor there are in restsharp:
request.AddFile
Now I have to call up a file in the folder that was created by the previous API call again and the second call through
request.AddFile("file", fileStream, filename);
insert the file in the folder?
or is it enough just one call?
Thanks for answers
What I have tried:
class Program
{
static void Main(string[] args)
{
var client = new RestClient("http://172.18.24.169");
client.Authenticator = new HttpBasicAuthenticator("Administrator", "Smart2019");
client.Timeout = -1;
var request = new RestRequest("/osrest/api/documents/insert", Method.POST);
request.AddHeader("content-type", "multipart/form-data");
request.AlwaysMultipartFormData = true;
request.AddParameter("Object", "{\"cabinet\": \"Posteingang\",\"name\": \"Posteingang\",\"objectTypeId\":" + " \"2\",\"fields\": {\"Eingangsdatum\": {\"value\": \"21.12.2020\"}}}");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
_ = new RestClient("http://172.18.24.169");
client.Authenticator = new HttpBasicAuthenticator("Administrator", "Smart2019");
client.Timeout = -1;
_ = new RestRequest("/osrest/api/documents/insert", Method.POST);
request.AddHeader("content-type", "multipart/form-data");
request.AlwaysMultipartFormData = true;
}
}