asp.net-web-api

Xamarin.Forms Upload Multiple Images with Data

*爱你&永不变心* 提交于 2021-02-04 21:40:40
问题 I have found several tutorials on how to upload an image or multiple images in Xamarin. However, I have not found how to send multiple images with each image containing some satellite data. This is how the model looks like on the server: public class AppFileDTO { public IFormFile File { get; set; } public string CategoryName { get; set; } public string CategoryDescription { get; set; } public string Detail { get; set; } } But the controller needs a list of data. Here is the Asp.Net Web Api

OData v4 groupby with $count

和自甴很熟 提交于 2021-02-03 09:28:05
问题 I'm using OData v4 with WebAPI with these nuget-packages: Microsoft.Data.OData 5.7.0 Microsoft.AspNet.WebApi.OData 4.0.30506 I can't get groupby to work with count. It should be the most simple thing. I have a simple table/entity called Delivery . It has a status column (among several other ones). What I basically want to do is this SQL query, but with OData: SELECT e.status, count(*) AS total FROM Delivery e GROUP BY e.status I've tried using countdistinct, but it doesn't give me the correct

OData v4 groupby with $count

杀马特。学长 韩版系。学妹 提交于 2021-02-03 09:25:59
问题 I'm using OData v4 with WebAPI with these nuget-packages: Microsoft.Data.OData 5.7.0 Microsoft.AspNet.WebApi.OData 4.0.30506 I can't get groupby to work with count. It should be the most simple thing. I have a simple table/entity called Delivery . It has a status column (among several other ones). What I basically want to do is this SQL query, but with OData: SELECT e.status, count(*) AS total FROM Delivery e GROUP BY e.status I've tried using countdistinct, but it doesn't give me the correct

QuickBooks Online Api Error “The remote server returned an error: (400) Bad Request”

陌路散爱 提交于 2021-01-29 20:31:17
问题 I'm using the QBO API and am at the step where I'm trying to retrieve the access and refresh tokens. When I send my request I get an error when I try to get the response that states "The remote server returned an error: (400) Bad Request". See the code below. I've tried a number of variations in my header, but cannot get it to work. Any ideas? Code (using vb.net): Sub Step2_GetTokens() 'Delcare variables. Dim vHTTPREQUEST As HttpWebRequest Dim vHTTPRESPONSE As HttpWebResponse Dim

How to validate if email attribute is unique in an ASP .NET CORE API?

别来无恙 提交于 2021-01-29 18:22:10
问题 I was needing to make a post or put a validation on the server side to check if the email is unique. In the research I have always done the example was a traditional MVC application and never an api. In many cases I saw that the [Remote] https://docs.microsoft.com/pt-br/aspnet/core/mvc/models/validation?view=aspnetcore-2.2#remote-attribute . I tried to implement according to the documentation, but debugging verified that the function in the controller is neither called. User.cs using System;

How to handle concurrency (status 409) errors using HttpContent in ASP.NET MVC Web application?

耗尽温柔 提交于 2021-01-29 15:31:07
问题 I'm working on a Core 3.1 Web API and an MVC application that uses it. In the MVC app I have UserRepo set up containing an Update method: public async Task<User> Update(User user) { HttpClient client = _clientFactory.CreateClient("namedClient"); HttpResponseMessage response = await client.PutAsync($"api/Users/{user.Id}", ContentEncoder.Encode(user)); try { response.EnsureSuccessStatusCode(); } catch (Exception ex) { if ((int)response.StatusCode == StatusCodes.Status409Conflict) { throw; } }

How to fix “AmbiguousMatchException: The request matched multiple endpoints.”

风流意气都作罢 提交于 2021-01-29 13:28:17
问题 https://i.imgur.com/JphyUEv.png After following this YouTube video https://youtu.be/PlW9dgU_aVM going through how to setup entity framework core database first CRUD operations in ASP.NET CORE Application. At this point https://youtu.be/PlW9dgU_aVM?t=578 an unhandled exception occurred while processing the request, how do I go about fixing the problem (Ref image above). P.S sorry for read and deciphering This is for a REST Api using entity framework core database first CRUD operations in ASP

How can I change Serialization approach (Typed,None) for some actions in Asp.Net Core?

我与影子孤独终老i 提交于 2021-01-29 11:10:51
问题 I have asp.net core 2.2 web Application. The application contains Command and Query Actions, Command Actions must return typed json response: { $type:"A.B.Customer, x.dll ", id: 11231, name: "Erwin .." } Query Actions must return non typed response: { id: 34234, name: "Erwin .. " } We can choose one outputformatter for Json responses at startup. services.AddMvc().AddJsonOptions(o => { SerializerSettings.TypeNameHandling=Newtonsoft.Json.TypeNameHandling.Objects // SerializerSettings

Keep on getting Unauthorize Web API

≡放荡痞女 提交于 2021-01-29 09:36:21
问题 I have a project, It's a web application that requires Windows Authentication. I've setup an Active Directory at home using my NAS virtualization. Then I've created a VMWare Server for IIS which is a member of that domain on my desktop which I also use for development. I've created the Web API and installed it into that VMWare server. When I call a routine directly, it works and return results but when I use the Web API routine from my javascript web application I keep on getting 401 error. I

Best practice to handle content in the response after a Web API call results in an exception

安稳与你 提交于 2021-01-29 08:53:07
问题 I'm working on a Core 3.1 Web API and an MVC application that uses it. In the MVC app I have UserRepo set up containing methods that send requests to the API: public class UserRepo : IUserRepo { private readonly IHttpClientFactory _clientFactory; public UserRepo(IHttpClientFactory httpClientFactory) { _clientFactory = httpClientFactory; } public async Task<User> GetById(int Id) { // same code structure as Update ... } public async Task<User> Update(User user) { HttpClient client =