Questions tagged [webapi2]

127 questions
0
votes
1 answer

How to properly handle & control Errors in Angular and Web API - 2

I am wondering how to properly handle and control errors in Angular & Web api, on some tutorial I saw that errors are handled in a component and not in a service which is fetching data.. and basically both backend and angular/clients erros are…
billy_56
  • 649
  • 3
  • 11
  • 27
0
votes
0 answers

special character "/" from angular4 to WebAPI2

i need to invoke web api2 from angular4 my url looks like below my url looks like api/schedule/getdata/date/2018-04-18/utilityid/utilityname/poolid/pool/name where poolid contains special characters for example: "pool/name". how can i pass this…
0
votes
1 answer

Consume the parameters of the method api c # put 2 (String, Object)

I am trying to consume an api of this type: api / food_order / {id} the idea is from a console project. I found this code: client.BaseAddress = new Uri ("http: // localhost: 1565 /"); var response = client.PutAsJsonAsync ("api / food_order", p)…
0
votes
1 answer

C# Web Api 2 use StructureMap to pass request data into injected dependency constructor parameter

I'm getting my feet wet with C# IoC frameworks. I chose StructureMap.Webapi2 to integrate into an existing api. I have the following scenario which I am not sure what the best way to implement is. public class MyController : ApiController { …
Bruno
  • 85
  • 1
  • 10
0
votes
1 answer

How do I resolve a WebAPI dependency in Autofac that requires a parameter from the route?

I am struggling with wiring dependencies through autofac in my WebApi 2 project. I have a following interface and class that i'd like to inject in my GET and POST controller actions, public interface IRepository { IContext Context { …
Usman Khan
  • 139
  • 2
  • 12
0
votes
1 answer

Web API 2, CORS, NTLM & OWIN / Katana with Angular 2

Massive amount of issues getting this to work. Thought I'd put up the common issues and the solutions having wasted a day on this and being led down many false paths by other answers. Setup : Web Api 2 Server Server configured for NTLM…
Rich Linnell
  • 973
  • 5
  • 14
0
votes
1 answer

asp.net-web-api using culture for returning errors in different languages

I'm using ASP.NET Web API 2, I have resx files for errors, I need to return the error in the correct language (by user culture). My solution is 1)I created BaseApiController that all the other controllers would inherit. 2)In BaseApiController I…
Gal Koren
  • 73
  • 1
  • 10
0
votes
0 answers

Access filter attributes from web API constructor C#

I feel fairly confident that I have this wrong (or backwards). I'm looking to determine what environment a request is coming from, so that I can determine what database to access (based on the referrer url). The end point is a "self-hosted" API…
0
votes
1 answer

How to write Division operation in WebApi2.0

In c# we have try & catch block we know how to avoid "Attempted to divide by zero But in WebAPi2.0 how can i Restricts user not Enter 1/0 Or -1/0 public IHttpActionResult div(int a, int b) { return Ok(a / b); }
user8311110
0
votes
2 answers

OWIN WebAPI 2 jQuery Ajax getting NetworkError

May I know the reason why the code below returns NetworkError when I try to invoke the WebAPI using jQuery Ajax? The Web Method was called successfully, but giving out error after it returned. I can access the Web Method using IE if I change the…
s k
  • 4,342
  • 3
  • 42
  • 61
0
votes
1 answer

ViewData is not working on Razor View on MVC Web API 2

Please help I am trying to create an Error View on MVC Web API and using custom filter and I am throwing all errors on controller's view and passing the data on ViewData and writing it on Razor View. My Controller (not ApiController) inside the…
Israel Ocbina
  • 517
  • 8
  • 14
0
votes
2 answers

Only want json returned when using WebApi 2 and EntityFramework

I am stumped on this for a couple of hours. I am using WebApi 2 and Entity Framework 6.1.3. I am following this tutorial: https://learn.microsoft.com/en-us/aspnet/web-api/overview/data/using-web-api-with-entity-framework/ I would like to return only…
hikerclimb
  • 21
  • 4
0
votes
1 answer

HTTPPOST request calling with string parameter

I have a POST request which have just a string parameter [HttpPost] public IHttpActionResult CheckMfaEnabled([FromBody]string userEmail)// { var isMfaEnabled = //use another service to return true/false return…
Sara N
  • 1,079
  • 5
  • 17
  • 45
0
votes
0 answers

Understanding Error Message

{ "message": "Foo request failed", "errors": [ "Error converting value {null} to type 'System.Boolean'. Path '[43].Group_Is_Full', line 1, position 30730.", "Null object cannot be converted to a value type." ] } My goal is to…
VSO
  • 11,546
  • 25
  • 99
  • 187
0
votes
1 answer

Accessing parameters of custom action filter attributes into IsAuthorized

I have created custom attribute for Web api 2. I inherited from Authorize attribute. New attribute takes params attribute like public MyAuthorizeAttribute(params string[] scopes){} and usage will be something like this…
1 2 3
8 9