Hi All,
I am trying to upload file into a repository through its Rest API using Restsharp. But getting below error, but the same working with postman.
07/02/2021 22:25:53 {"data": {
"response": "400",
"reason": "0602519762 There is no JSON file"
}}
I have to create and pass a JSON file for the folder details where the file needs to be uploaded and I have to pass the file to be uploaded.
This is the code I am trying using Invoke code activity
var client = new RestClient("http://service/documentCreate?");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Basic cGFydGhhc2FyYXR=");
request.AddHeader("Content-Type", "multipart/form-data;");
request.AddFile("File", @"D:\DocUpload\TestFile.txt");
request.AddFile("JSON", @"D:\DocUpload\doccreate.json");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);