I want to write a http request in Ionic 2 to call API in Paypal and get the Http response for further processing. The API via curl is like following (https://developer.paypal.com/docs/integration/mobile/verify-mobile-payment/)
curl https://api.sandbox.paypal.com/v1/payments/payment/PAY-5YK922393D847794YKER7MUI \
-H "Content-Type: application/json" \
-H "Authorization: Bearer accessToken" //assume accessToken=1234
The following is my code:
let headers = new Headers(); headers.append('Content-Type', 'application/json'); headers.append('Authorization', 'Bearer 1234'); //accessToken=1234 var response = this.http.post('https://api.sandbox.paypal.com/v1/payments/payment/PAY-5YK922393D847794YKER7MUI',"null",{headers: headers}).map(res=>res.json()); response.subscribe(data=>{ console.log(data); console.log(JSON.stringify(data)); //I need to get the HTTP response data for further processing. });
However, the console said “500 (Internal Server Error)”.
So, could anyone please help me? thank you.