Hi Martin,wi

your code looks fine to me - I have a springboot java app as backend and my 
service call looks like this:

        this.http.put('/api/item', item).subscribe(
            result => {
                console.log('result: ', result);
                this.router.navigate(['/']);
            }
        );

When looking into my request in firefox console:

URL: 
http://laptop/api/item (laptop is my local dev machine)

Request Headers: 
Host: laptop
User-Agent: Mozilla/...
Accept: application/json, text/plain, */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://laptop/item/create
Content-Type: application/json
Content-Length: 15
Connection: keep-alive

Request Body:
{"name":"Test"}

My suggestion for solving your issues would be the following:

1. trace the request / response with either the debug / network console in 
firefox (or chrome)
2. look into what is sent by the angular application over the network
3. get a plugin like RESTer for Firefox and try play around with the 
request until the server accepts it
4. apply the changes to your angular code

Kinde regards, Manuel


Am Freitag, 9. Februar 2018 12:36:50 UTC+1 schrieb Martin Kuenz:
>
> I have a Question for angular 5. I become an API Call to make this over 
> angular but I become always a bad request from the API IIS Server. <br>
> This is the String<br> `With the Methode POST
>
> On the http-Header:
> Accept: text/javascript
>
> Content-Type: application/json
>
> I'm Body: {encodedetUrl}
>
>
> and this is my Code i take
>
>    getPosition(sql: string): Observable<Position[]> {
>
>         let headers = new HttpHeaders().set('Content-Type', 
> 'application/json');
>     headers = headers.set('Accept', 'text/javascript');
>
>         let sqlstring = encodeURIComponent(sql);
>
>        
>  let string = '{"Befehl": "' + sqlstring + '","Datenbank": 
> "DBScharnsteinTest", "Login": "username", "Passwort": "password", 
> "PKMitarbeiterID": "2640"}';
>         console.log();
>         return this.httpClient.post<Position[]> (this.url, string, {
> headers});
>         
>       }
>
>
>
> Can anybody Help me why that not work.
>
> Thx
>

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to