500 (Internal Server Error) on http.post in angular 2+

Discussão em 'Angular' iniciado por Hunter D, Dezembro 4, 2024.

  1. Hunter D

    Hunter D Guest

    My service function:

    public postDetails(Details): Observable<any> {
    let cpHeaders = new Headers({ 'Content-Type': 'application/json' });
    let options = new RequestOptions({ headers: cpHeaders });
    return this.http.post(this.baseUrl + "/api/adm/Dtls", Details,options)
    .map((res: any) => {
    let data = res.json();
    return data; })
    }


    TS file.

    let postdata:any= JSON.stringify(Details);

    this.data = this.storageservice.postDetails(postdata);
    this.data.subscribe((result: any) => {
    if (result) {
    console.log(result);
    }
    });


    Error on Browser

    OPTIONS http://10.23.233.45/statapi/api/details/Dtls 500 (Internal Server Error)
    Failed to load http://10.23.233.45/statapi/api/details/Dtls: Response for preflight has invalid HTTP status code 500.
    core.js:1448 ERROR Response {_body: ProgressEvent, status: 0, ok: false, statusText: "", headers: Headers, …}


    I am able to post the data using Postman, but I am not able to send data through angular, I have no clue what's the issue.

    Continue reading...

Compartilhe esta Página