Comments (7)
Hi @rcalderoni
You need to use an IList type to import the data. In your Controller, your import method should look something like this:
[HttpPost]
[Route("import")]
public IActionResult Import([FromBody]List<CustomerPlanModel> value)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
else
{
List<CustomerPlanModel> data = value;
return Ok();
}
}
Can you check this or post your Controller import method and I can check it?
If this is ok, can you post me your Controller code for the import and also the project.json
Greetings Damien
from aspnetcorecsvimportexport.
yep, that's what I've got as well, makes me wonder if it's a compatibility issue since I am using the latest .NET Core SDK, I'll report back if I find any fixes in that case
[HttpPost]
[Route("import")]
public IActionResult Import([FromBody]List<CustomerPlanModel> value)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
else
{
List<CustomerPlanModel> data = value;
return Ok();
}
}
public void ConfigureServices(IServiceCollection services)
{
var csvFormatterOptions = new CsvFormatterOptions();
// Add framework services.
services.AddMvc(options =>
{
options.InputFormatters.Add(new CsvInputFormatter(csvFormatterOptions));
options.OutputFormatters.Add(new CsvOutputFormatter(csvFormatterOptions));
options.FormatterMappings.SetMediaTypeMappingForFormat("csv", MediaTypeHeaderValue.Parse("text/csv"));
});
services.AddTransient<IReportFilterService, ReportFilterService>();
services.AddTransient<IReportFilterRepository, ReportFilterRepository>();
}
from aspnetcorecsvimportexport.
If your using the an older version, then it's a compatibility issue, you need to change the Activator. The code works with the actual version of ASP.NET Core.
Greetings Damien
from aspnetcorecsvimportexport.
can I close this issue?
from aspnetcorecsvimportexport.
from aspnetcorecsvimportexport.
OK, I'll check it again with Version ASP.NET Core 1.1 and if it works, I'll close the issue.
Thanks for the replay
Greetings Damien
from aspnetcorecsvimportexport.
I checked this and it works without problems.
https://github.com/damienbod/AspNetCoreCsvImportExport/tree/delimiterTestComma
This was the update in ASP.NET Core version which caused this mismatch. Sorry this solution did not work for you.
Greetings Damien
from aspnetcorecsvimportexport.
Related Issues (15)
- Does this handle nested complex data? HOT 1
- NuGet package HOT 1
- Returning the data as a file? HOT 3
- Package divergence between damienbod/AspNetCoreCsvImportExport and damienbod/WebAPIContrib.Core HOT 1
- export data.csv for GET method with query parameters? HOT 3
- Generric import & export - for runtime file import
- Typo in project title HOT 1
- NuGet with .NET 3.0 updates?
- Demo code threw this exception HOT 2
- DateTime HOT 1
- Default file name for exported csv file HOT 2
- Bug, improvement
- How to Upload File HOT 2
- Ignore Properties in CSV HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aspnetcorecsvimportexport.