I am converting web application to mobile app. We were using AjaxAsyncFileUpload
in web application to save a document to the server, where AjaxAsyncFileUpload
use to do the work for me. This was the code
Dim fileData As Byte() =new Byte(AjaxAsyncFileUpload.FileContent.Length-1){}
AjaxAsyncFileUpload.FileContent.Read(fileData, 0, fileData.Length)
InvestmentDeclare.DocSize = AjaxAsyncFileUpload.FileContent.Length
InvestmentDeclare.DocFileName = AjaxAsyncFileUpload.FileName
InvestmentDeclare.DocFileType = AjaxAsyncFileUpload.PostedFile.ContentType
InvestmentDeclare.Document = fileData
And then simply save this to my database.
Now while Converting this to mobile app (I am also using c# for mobile app), I am not able to pass the byte array. I am using fiddler for testing. I have attached an image of how I'm passing it through fiddler. In my API POST method I'm getting a null value to my document variable while I'm able to get rest of my values properly.
What could be the issue? Am I not passing the byte in proper Json format?
In API:
public class AddInvestmentDeclare
{
public int EmployeeId { get; set; }
public int YearId { get; set; }
public int InvestmentId { get; set; }
public List<EmpDocument> EmpDocuments { get; set; }
}
public class EmpDocument
{
public byte[] Document { get; set; }
public string DocumentFileName { get; set; }
public long DocumentSize { get; set; }
public string DocumentType { get; set; }
}
public HttpResponseMessage Post(int YearId, [FromBody]List<AddInvestmentDeclare> InvestmentDeclared)
{
When I check my InvestDeclared
list on run time I see that document variable is not filled and it is showing null. I have attached an image of that as well.