2016-12-15 149 views
0

我是Mulesoft的新手,並試圖發送一些(四個)查詢參數。 「:」 INVALID_REQUEST 「 」ERROR_DESCRIPTION當使用SOAP UI A screen shot of what I tested如何將查詢字符串傳遞給使用mulesoft的發佈請求

測試我使用下面的XML配置

<flow name="boxintegrationFlow1"> 
    <http:listener config-ref="HTTP_Listener_Configuration1" path="*" doc:name="HTTP"/> 
    <logger message="Message: #[message.inboundProperties] Code: #[message.inboundProperties.'http.query.params'.code]" level="INFO" doc:name="Logger"/> 
    <set-property propertyName="Content-Type" value="application/x-www-form-urlencoded" doc:name="Property"/> 
    <set-variable variableName="QueryParameters" value="{'grant_type':'authorization_code', 'code':''#[message.inboundProperties.'http.query.params'.code]','client_id':'abc','client_secret':'xyz'}" doc:name="Variable" mimeType="application/x-www-form-urlencoded"/> 
    <logger message="#[flowVars.QueryParameters]" level="INFO" doc:name="Logger"/> 
    <set-payload value="#[flowVars.QueryParameters]" doc:name="PostQueryParameters"/> 
    <http:request config-ref="getToken" path="/oauth2/token" method="POST" sendBodyMode="ALWAYS" doc:name="HTTP"> 
     <http:request-builder> 
      <http:query-param paramName="grant_type" value="authorization_code"/> 
      <http:query-param paramName="code" value="#[message.inboundProperties.'http.query.params'.code]"/> 
      <http:query-param paramName="client_id" value="xyz"/> 
      <http:query-param paramName="client_secret" value="abc"/> 
     </http:request-builder> 
     <http:success-status-code-validator values="400"/> 
    </http:request> 
    <logger message="Message: #[message.outboundProperties] " level="INFO" doc:name="Logger"/> 
</flow> 

在這樣做我得到一個錯誤 「{」 錯誤重複這mulesoft「:」無效的grant_type參數或參數缺失「}」

我明白我們已經將它作爲查詢字符串傳遞,但我無法弄清楚我該如何做。

任何指針表示讚賞。先謝謝你!

回答

0

錯誤顯示您正在使用Mule OAuth provider或類似的東西。如果是這樣,你的問題不是你不正確地添加grant_type作爲查詢參數,而是你發送客戶端ID和密碼作爲參數。

您需要將您的客戶端ID和密碼作爲基本驗證標頭髮送。標題的格式應該是Authorization: Basic NmJlXXXXXXXXXXc0NDZlYmFhNTgzMWQ0NDRhZmNjMmE6MzJkZTE1ZDZZZZZZZZZZZkFEOEJEQUU5QkNG

示例使用curl給騾子的OAuth提供本地運行(使用資源的用戶名/密碼交付式):

curl -i -X POST -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: Basic NmJlXXXXXXXXXXc0NDZlYmFhNTgzMWQ0NDRhZmNjMmE6MzJkZTE1ZDZZZZZZZZZZZkFEOEJEQUU5QkNGMjc4RDYK" -d "grant_type=password&username=max&password=mule" "https://localhost:10101/external/access_token" -k 
+0

其工作正常,當我測試它。在那裏發送它作爲查詢參數。 –

+0

您還在查詢字符串和帖子正文中設置參數。你應該只在一個地方做。我知道騾OAuth提供商會給你一個錯誤,如果你把它放在兩個地方。刪除身體,只使用查詢字符串,反之亦然。這可能是你的問題。 – Charles

+0

感謝您的快速回復..建議我嘗試刪除它們在一個地方。 –

相關問題