title: Retrieve XML from HTTPClient on Angular 5
body: <p>I'm trying to retrieve an xml from a <strong>SOAP API</strong> using the <a href="https://angular.io/guide/http" rel="nofollow noreferrer">HttpClient</a> from Angular</p>
  
  <p>This is what's on my <strong>app.component.html</strong>:</p>
  
  <pre><code>&lt;input type="submit" value="test POST" (click)="onClickMe()"/&gt;
  </code></pre>
  
  <p>This is on my <strong>app.component.ts</strong></p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  import { HttpClient } from '@angular/common/http';
  import { HttpErrorResponse } from '@angular/common/http';
  import { HttpHeaders } from '@angular/common/http';
  
  @Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
  })
  export class AppComponent implements OnInit {
  
    results: string[];
    constructor(private http: HttpClient) {
      console.log('constructor opened');
  
    }
    ngOnInit(): void{
      console.log('onInit opened'); 
  
      }
  
    onClickMe(){
        var emp = '&lt;&lt;credentials to the webservice&gt;&gt;';
        var login = '&lt;&lt;credentials to the webservice&gt;&gt;';
        var pass = '&lt;&lt;credentials to the webservice&gt;&gt;';
        var id = "&lt;&lt;credentials to the webservice&gt;&gt;";
  
        const body = "&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\"&gt;\r\n  &lt;soap12:Body&gt;\r\n    &lt;Lista xmlns=\"http://GSMMX.WebService/\"&gt;\r\n      &lt;Emp&gt;"+emp+"&lt;/Emp&gt;\r\n      &lt;Login&gt;"+ login +"&lt;/Login&gt;\r\n      &lt;Senha&gt;"+ pass +"&lt;/Senha&gt;\r\n      &lt;id&gt;"+ id +"&lt;/id&gt;\r\n    &lt;/Lista&gt;\r\n  &lt;/soap12:Body&gt;\r\n&lt;/soap12:Envelope&gt;";
        const url = "&lt;&lt;webserviceURL&gt;&gt;";
        console.log('onClickme opened');
  
        this.http.post(url, body, {
          headers: new HttpHeaders()
          .set('Content-Type', 'text/xml') 
          .append('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,PATCH,OPTIONS') 
          .append('Access-Control-Allow-Origin', '*')
          .append('Access-Control-Allow-Headers', "Access-Control-Allow-Headers, Access-Control-Allow-Origin, Access-Control-Request-Method")
    }).subscribe(data =&gt; {
          console.log(data);
  
        },
        (err: HttpErrorResponse) =&gt; {
          if (err.error instanceof Error) {
            // A client-side or network error occurred. Handle it accordingly.
            console.log('An error occurred:', err.error.message);
          } else {
            // The backend returned an unsuccessful response code.
            // The response body may contain clues as to what went wrong,
            console.log(`Backend returned code ${err.status}, body was: ${err.error}`);
          }
        }
      );
  
    }
  
  
  }
  </code></pre>
  
  <p>So, I did the same request using Postman and copied the url and body exactly as the succeeded POST worked. I tried to do that using Angular 5 and it's not working, it's returning the following message:</p>
  
  <pre><code>Backend returned code 200, body was: [object Object]
  </code></pre>
  
  <p>Does someone know how do I make this work? The request is getting a 200 code but the response is not coming the right way.</p>
  
  <p>I appreciate any help!</p>