Angular 2 HTTP post to Web API without [FromBody]

Issue I have a sample Angular 2 code below. this.headers = new Headers({ ‘Content-Type’: ‘application/json’ }); this.options = new RequestOptions({ headers: this.headers }); this.http.post(‘/api/todo/create’, JSON.stringify(todo), this.options); I also have an API action as seen below (ASP.NET Core) [HttpPost] [Route(“create”)] public

Continue reading

Cross Origin preflight request in Nginx Proxy

Issue Getting this error when accessing from browser Access to XMLHttpRequest at ‘https://api.example.com/users/authenticate’ from origin ‘https://example.com’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource

Continue reading

Does not trigger the Web API from Angular 5

Issue I have attached my Component.ts, service.TS, AND in Web Api. Can you help me to get data from SP. I am using MVC . This is my component.ts GetComponentListForGrid() {this._componentservice.getAllComponentList(this.compartid_auto,this.progid,this.ComponentId,this.ComponentDescription,this.ComponentType, this.ComponentMake,this.EquipModel).subscribe(result => { console.log(‘GetAvailableCompartsAll’, result); this._componentList.push(…result); }, error =>

Continue reading

Differentiate between HTTP request and Ajax request

Issue I am currently working on ASP.NET WebApi and Angularjs WebApi have a method [System.Web.Http.AcceptVerbs(“POST”)] [System.Web.Http.HttpPost] public HttpResponseMessage SearchAddress(SearchDetails searchDetail) { //13.03993,80.231867 try { if (!WebSecurity.IsAuthenticated) { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.NotAcceptable); return response; } List<CollegeAddress> CollegeAddress = addressService.GetAddressFromDistance(17.380498, 78.4864948, 2000);

Continue reading

Http headers passed from Angular 8 are not appearing in HttpContext in ASP.NET Core API 3.1

Issue I am passing some header values to my API call in an Angular application: httpOptions = { headers: new HttpHeaders({ "Content-Type": "application/json", "Access-Control-Allow-Origin": "*", "xibm-clientid": "Test" }) }; submitSomething(myData: IMyData): Observable<any> { return this.httpClient .post<any>(apiURL, JSON.stringify(myData), this.httpOptions) .pipe(catchError(this.errorHandler)); }

Continue reading

Angular 8 – Can not call webapi

Issue I am trying to get data from web api using parameter.i can’t get data.no t showing error message also. dash board component Countrymodel: Country = { country_id: ”, country_name: ”, status: false } Countries: Observable; constructor(private api: RestApiService, private

Continue reading