2016-03-07 54 views
1

我试图使用WSO2 StoreAPI在我的代码从WSO2.Here进行验证是一个片段WSO2空响应

def wso2Subscription(){ 
     println "Inside Subscription" 
     def serverName = grailsApplication.config.grails.wsoconfig.serverName.toString() 
     println serverName 
     withHttp(uri: serverName) { 
      def resp = post(path : '/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag', query : [action:'addAPISubscription',name:'NewAPI',version:'1.0.0',provider:'admin',tier:'Unlimited',applicationName:'DefaultApplication']) 
      println "Subscription Response from WS02 ="+resp 
      resp.each { h -> println " ${h.key} : ${h.value}" } 
     } 
    } 

RESP的该值为null每次。这里缺少什么?我已经登录并执行此操作。此外,用户以前未订阅此API。显示“Inside Subscription”,因此该功能正在调用。但是,响应始终为空。出了什么问题?

回答

1

您应该将以下信息作为正文发送,而不是查询字符串。

action:'addAPISubscription',name:'NewAPI',version:'1.0.0',provider:'admin',tier:'Unlimited',applicationName:'DefaultApplication' 

您最好从cURL发送请求并查看响应。

+0

我只能在首次登录后才能从cURL获得响应。在这里,我正在登录,但我觉得它无法击中Url。可能cURL可以选择发布到cookie,而这里不存在。那么其他方式呢? –