2015-02-07 99 views
0

目前我正在使用paypal API並與此文檔make your first call一起流動。PayPal API with angular and cURL

當我通過角度$ http發送一個請求到貝寶,我得到了一個狀態碼415.這似乎是我錯過了什麼,有沒有人可以幫助我? :)

here is my code 
$http({ 
     url: 'https://api.sandbox.paypal.com/v1/oauth2/token', 
     method: 'POST', 
     headers: {'Content-Type': 'application/json', 
        'auth-token': 'EOJ2S-Z6OoN_le_KS1d75wsZ6y0SFdVsY9183IvxFyZp EClusMEUk8e9ihI7ZdVLF5cZ6y0SFdVsY9183IvxFyZp', 
        'Accept-Language': 'en_US' 
        }, 
     data: { 'grant_type': 'client_credentials' } 
}).success(function (data, status, headers, config) { 
      console.log(data) 
}).error(function (data, status, headers, config) { 
      console.log(data) 
}); 

回答

0

參照貝寶DOC

提示:如果您正在使用Windows,我們建議您讓使用 的Bash shell捲曲的電話。如果您未使用cURL調用,請將內容類型設置爲 application/x-www-form-urlencoded以獲取此請求。

嘗試設置content_typeapplication/x-www-form-urlencoded

+0

感謝Rebornixm,它的作品! – Aiden 2015-02-07 14:26:49

+0

太棒了!你可能想接受我的答案爲正確:) – Rebornix 2015-02-07 14:27:46

+0

嗨,Rebornixm,我遇到了一個新問題。你能再次幫助我嗎,非常感謝。 :) [新問題](http://stackoverflow.com/questions/28384174/paypal-api-with-angular-400-bad-request) – Aiden 2015-02-07 15:57:04