Mohamad nagi
Mohamad nagi

Reputation: 101

Send Post request with parameters in URL

After any sign up I push the user to verify his account. I send the verification code to his email and he adds it in input and sends that value by post API call. My problem is when I make a request I get a response with 203 Non-Authoritative Information. But when I try this process with PostMan it works fine

My Componant Code :

  verfiy(){

  this.code = this.userverfiycode.verfiCode;


this.authService.postData('Verify?userId='+this.user +'&vCode='+ this.code ).then((result) => {

  this.responseData = result;
  console.log(this.responseData);
  console.log(this.user);
  console.log(this.code);
  console.log(this.type);



  if (this.responseData = true) {

    this.pushpage()

  }

  else{

    console.log("");

      }
    }, (err) => {
     // Error log


    });

 }

my Provider Code :

 let apiUrl = 'http://localhost:50494/api/Account/';
 let apiKey = 'sdf4rw-23fs-3454-fsdsd-3we2693243424';


 @Injectable()
 export class AuthProvider {




 constructor(public http : Http) {
 console.log('Hello AuthService Provider');



}

UserKey = localStorage.getItem('loginData');


postData( type) {
 return new Promise((resolve, reject) => {
  let headers = new Headers();
  headers.append('Content-Type', 'application/json');
  headers.append('token', apiKey);
  headers.append('api_key', this.UserKey);



   this.http.post(apiUrl + type, {headers: headers})
     .subscribe(res => {


      resolve();
      console.log()

    }, (err) => {
      reject(err);
      console.log()


    });
  });
}

Upvotes: 0

Views: 702

Answers (1)

Vivek Kumar
Vivek Kumar

Reputation: 5040

generally, the second parameter of post() is data and third is {headers};

Can you try sending some dummy data

this.http.post(apiUrl + type, {}, {headers: headers})
     .subscribe(res => {});

I thinking so because the backend is not getting the headers you are sending in the post() function.

Can you please check your devtool network tab for this request, if the Request Headers are going properly or not

Upvotes: 2

Related Questions