2013-12-11 76 views
0

我正在使用WSO2 esb 4.8.0並試圖對PayPal API OAuth請求(request with title OAuth Request/Response)進行REST調用。請求的內容類型需要爲application/x-www-form-urlencoded。我試圖用幾種方法來做到這一點。發送帶有應用程序/ x-www-form-urlencoded編碼的表單數據,內部有效負載

for better code view please refer this

  1. <payloadFactory media-type="json"> <format> { "grant_type":"client_credentials" } </format>
    </payloadFactory>
    <property name="messageType" value="application/x-www-form-urlencoded" scope="axis2"/>
    <call> <endpoint> <http method="post" uri-template="https://api.sandbox.paypal.com/v1/oauth2/token?grant_type=client_credentials"/> <property name="grant_type" value="client_credentials"/> </endpoint> </call>

是的,我已經包括了3種可能(似乎是可能的)在一次代碼的方式(並試圖爲好)撥打這通電話。但是帖子參數沒有正確傳遞到結束點。我使用HTTP/1.1 400代碼獲得以下響應。

{"error":"invalid_request","error_description":"grant_type is a required parameter"} 

感謝有人能幫助我解決這個問題。

回答

0

我已經嘗試了與貝寶相同的方案來獲取oAuth令牌。參考以下配置

<property name="DISABLE_CHUNKING" value="true" scope="axis2" type="STRING"/> 
<property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/> 
<payloadFactory media-type="xml"> 
    <format> 
     <POST xmlns=""> 
      <grant_type>client_credentials</grant_type> 
     </POST> 
    </format> 
    <args/> 
</payloadFactory> 
<property name="messageType" value="application/x-www-form-urlencoded" scope="axis2" type="STRING"/> 
<send> 
    <endpoint> 
     <address uri="https://api.sandbox.paypal.com/v1/oauth2/token"/> 
    </endpoint> 
</send> 
相關問題