asp.net-web-api2

Get OAuth Token from Web API to android

倖福魔咒の 提交于 2019-12-25 04:46:17
问题 I'm trying to get ِِOAuth token in android from my web api. I have tested the api in Postman and it's working perfect. Screenshot for the successful call from Postman now I need to call this Api from my android app using retrofit 2 to get the token, for that I tried to use the following interface but it's not working. @FormUrlEncoded @POST("/Token") public Call<String> Token(@Field("grant_type") String grant_type, @Field("username") String username, @Field("password") String password); How

WebAPI Url.Link() returning NULL

若如初见. 提交于 2019-12-25 04:42:50
问题 I am having some trouble in generating WebAPI hypermedia links in a project I am working on. In the code snippet below the extension methods Order , OrderUpdate and OrderDelete for individual orders are all returning Null links. I suspect this is because WebAPI is unable to resolve these inner routes from the parent Orders route. I am not certain why Null links are being returned as I am supplying valid route names to the Link method. You can see from the resulting JSON output that the Uri

Create an ODataQueryOptions programmatically

为君一笑 提交于 2019-12-25 03:17:08
问题 My API currently has some OData endpoints that use generic ODataQueryOptions to recieve an OData query... [HttpGet] [Route("search")] public object Search(ODataQueryOptions<MySearchableEntity> options) { return searchService.Search(options); } searchService then traverses the Expression of options.Filter.FilterClause to build a custom SQL query. It does similar stuff for the order, top and skip parameters. This is all working fine, but I now need it to parse a query for a dynamic type. Is it

Create an ODataQueryOptions programmatically

こ雲淡風輕ζ 提交于 2019-12-25 03:17:06
问题 My API currently has some OData endpoints that use generic ODataQueryOptions to recieve an OData query... [HttpGet] [Route("search")] public object Search(ODataQueryOptions<MySearchableEntity> options) { return searchService.Search(options); } searchService then traverses the Expression of options.Filter.FilterClause to build a custom SQL query. It does similar stuff for the order, top and skip parameters. This is all working fine, but I now need it to parse a query for a dynamic type. Is it

AutoFac MVC Web API

情到浓时终转凉″ 提交于 2019-12-25 03:12:57
问题 I have a simple AutoFac example working but now want to apply this to my web api project AND have the correct separation between the layers. The issue I am seeing is the standard controller x "does not have a default constructor" but i am stumped so asking for advice.. I am calling RegisterApiControllers as well as RegisterControllers.. this is what I have in my DependencyInjectionContainer public static class DependencyInjectionContainer { public static ContainerBuilder Builder; public

Microsoft Graph API call hangs indefinitely

独自空忆成欢 提交于 2019-12-25 00:40:23
问题 I am attempting to query user information via Microsoft Graph. I can authenticate fine but when I attempt to query user information graphServiceClient.Users my application hangs indefinitely: no timeout, no error, just hangs. I found this post however the suggestions there did not help me. Here is my code: public bool GetUserByUniqueID(string uid, out GraphUser user) { bool ret = false; user = new GraphUser(); if (Authenticate(out AuthToken token)) { GraphServiceClient graphServiceClient =

Should I try to take BadRequest(ModelState) returned from my API, and deserialize to *what* with JSON.NET?

假如想象 提交于 2019-12-24 20:25:20
问题 TL;DR; "I like how my generated AutoRest client deserializes my main entities when dealing with the 200 scenarios.. but, MUST I manually parse the 400 scenarios?", said the lazy programmer DETAILS: So, I have an API, (Web API 2), and I do all the standard stuff.. using POCO's that implement IValidatable in addition to property-level validation using System.Data.DataAnnotations my Web API returns 400 errors like this (just an example): if (!ModelState.IsValid) { return BadRequest(ModelState);

Working with date time in web api

感情迁移 提交于 2019-12-24 18:49:25
问题 I have created a WEB API using MySQL database. The table includes the data about the meter's serial numbers it's signal strength values and the date time on which the signal strength has comes. For now i am successful in getting data by sending the meter's serial number. Now I am also sending the date time parameter to it also. But it's not working for me. Below is what i have done. public HttpResponseMessage GetByMsn(string msn, DateTime dt) { try { return Request.CreateResponse

Multiple POST methods OData Web API. Should/can it happen?

断了今生、忘了曾经 提交于 2019-12-24 17:48:51
问题 This question is perhaps an idealogical one... I have a requirement to create multiple records from an application calling an OData Web API through a service proxy. At the moment, I'm doing this by invoking the post method multiple times (through a service proxy) and then calling save changes to batch the requests. Eg. container.AddToColours(new Colour { Id = 1, Name = "Green" }); container.AddToColours(new Colour { Id = 2, Name = "Orange" }); container.SaveChanges(SaveChangesOptions.Batch);

Azure hosted api bearer tokens wont decrypt with context.DeserializeTicket?

徘徊边缘 提交于 2019-12-24 17:30:01
问题 I have 2 webapi2 projects that use the same database. If I'm on localhost I get a bearer token from one I can pass it to the other and the other will properly decrypt it and load the user. However when I publish them to separate urls on azure, I get the one token fine from one but when I pass it to the other I can't get the ticket to load and it gives me the unauthorized response. I'm testing this by watching the owin AuthenticationTokenProvider.OnRecieve method. When context