Angular 6 HttpErrorResponse on Get with 200 status

2,951 views
Skip to first unread message

Knight

unread,
May 5, 2019, 6:48:40 PM5/5/19
to Angular and AngularJS discussion

<p>
<i>
<code>
DOM7011: The code on this page disabled back and forward caching. For more information, see: http://go.microsoft.com/fwlink/?LinkID=291337
report
HTML1300: Navigation occurred.
report
In Report Component init
In connectToJasperconnected
[object Object]
   {
      [functions]: ,
      __proto__: { },
      error: { },
      headers: { },
      message: "Http failure during parsing for THE URL",
      name: "HttpErrorResponse",
      ok: false,
      status: 200,
      statusText: "OK",
      Symbol(INITIAL_VALUE)_h.bdyrahld8ry: undefined,
      Symbol(rxSubscriber)_g.bdyrahld8ry: undefined,
      Symbol(rxSubscriber)_i.bdyrahld8ry: undefined,
      url: "THE URL"
   }



Server Error Status: 200  <-- coming from the error routine
Error Connecting to Jasper Server: [object Object]    <-- coming from the error routine defined in component

</i>

<b>Component code</b>

  ngOnInit(): void {
    console.log('In Report Component init');
    this.connectToJasper();
  }

  connectToJasper() {
    this.samlConnectionService.
    getSAMLConnection().
    subscribe(
      data => this.connected = true,
      error => console.log('Error Connecting to Jasper Server: ' + error)
    );
    console.log('In connectToJasperconnected');
  }

<b>Service code</b>

jasperSamlURL = 'THE URL';

  getSAMLConnection(): Observable<any>  {
   // return this.httpClient.get<any>(this.jasperSamlURL, { responseType: 'text'})
   // return this.httpClient.post<any>(this.jasperSamlURL, { observe: 'response'})
    return this.httpClient.get(this.jasperSamlURL, { observe: 'response', responseType: 'text' })
    .pipe(
      tap(response => {
        console.log('Http Response Status: ' + response.status);
        console.log('Http Response text: ' + response.statusText);
        console.log('Http Response Type: ' + response.type);
        console.log('Http Response Body: ' + response.body);
      }),
      map(response => this.HttpResponseCode = response.status),
       catchError(this.handleError)
      );
  }

  public handleError(err) {
    if (err instanceof HttpErrorResponse) {
      // Server side Error
      this.HttpResponseCode = err.status;
      console.log(err);
      console.log('Server Error Status: ' + err.status);
    } else {
      // Client side error
      this.HttpResponseCode = err.status;
      console.log('Client Error Status: ' + err.status);
    }
    return throwError(err);
  }
</code>

Knight

unread,
May 5, 2019, 6:50:16 PM5/5/19
to Angular and AngularJS discussion
This code is making a call to Jasper server to establish a connection using SAML authentication. When the code is executed it jumps to handleError routine, although it is 200 but still having a parsing error. Here is the console info when the code is executed

Lucas Lacroix

unread,
May 5, 2019, 7:25:29 PM5/5/19
to ang...@googlegroups.com
It looks like an exception is being thrown while processing the request. According to the error, you are not passing a proper URL and it looks like you're trying to do a GET on "THE URL". Check out the value of "this.jasperSamlURL".

--
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 angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

                
Subscribe to receive emails from MEDITECH or to change email preferences.
Reply all
Reply to author
Forward
0 new messages