Hello Everyone,
I have requirement to pick the file from local path and attach a file using REST API from code level to the Sales Order. Can you please share the sample example for the same?
Hello Everyone,
I have requirement to pick the file from local path and attach a file using REST API from code level to the Sales Order. Can you please share the sample example for the same?
Best answer by Naveen Boga
RestClient client1 = new RestClient("http://localhost/23R2/entity/Default/23.200.001/");
RestRequest updateRequest = new RestRequest("StockItem/" + stock.InventoryID + "/files/" + stock.FileName, Method.Put);
updateRequest.AddHeader("Authorization", "Bearer " + authToken);
string filePath = @stock.Path;
//string filePath = @"D:\Test Key.txt";
byte[] fileData = File.ReadAllBytes(filePath);
updateRequest.AddParameter("image/png", fileData, ParameterType.RequestBody);
RestResponse updateResponse = await client1.ExecuteAsync(updateRequest);
if (updateResponse.IsSuccessful)
{
//logic here
}
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.