Posts behave differently


#1

Hello,

I make two posts testing in ios simulator:

  1. with angular http which works fine
public login(): Observable<string> {  
  let headers = new Headers({'Content-Type': 'application/x-www-form-urlencoded'});
    let options = new RequestOptions({headers: headers, withCredentials: true});
    let params: URLSearchParams = new URLSearchParams();
    params.set('target', 'XXX');
    params.set('username', XXX);
    params.set('password', XXX);
    return this.http.post(BACKEND_URL, params, options)
      .map(this.returnData)
      .catch(this.handleError);
}
  1. with native http using cordova gets an error
public login(): Observable<string> {  
 let params = {
      'target': 'XXX',
      'username': XXX,
      'password': XXX
    };
      let headers = {'Content-Type': 'application/x-www-form-urlencoded'};
    this.http.acceptAllCerts(true);
     this.http.disableRedirect(false);
    let responseData = this.http.post(BACKEND_URL, JSON.stringify(params), headers);
    return Observable.fromPromise(responseData)
      .map(this.returnData)
      .catch(this.handleError);
}

I am looking for a solution a long time but can’t find any :frowning:
I place the cacerts file in target folder created in project folder.

Can someone help please


#2

The error is no target is defined. But I add it to the body. Please help


#3

Post the complete and exact error message please.


#4

From console: 404 - undefined


#5

The redirect is not made, but I dont know why. It is specified in the body.
The first approach witn angular-http works.


#6

Fixed make the body as string seperated each param with &