2016-12-15 141 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

感谢您的快速回复..建议我尝试删除它们在一个地方。 –

相关问题