【问题标题】:How to do a GET with multiple times the same parameters using httpbuilder and groovy?如何使用httpbuilder和groovy进行多次相同参数的GET?
【发布时间】:2011-09-21 20:02:40
【问题描述】:

我正在使用 Groovy 1.8 和 HttpBuilder 0.5.1 与 REST Web 界面通信。我有这个工作:

def JSONArray tasks = httpBuilder.get( path: 'workspaces/'+LP_WORKSPACE_ID+'/tasks', query: [filter:'is_done is false'] );
def JSONArray tasks = httpBuilder.get( path: 'workspaces/'+LP_WORKSPACE_ID+'/tasks', query: [filter:'external_reference contains /'] );

我需要将这 2 合并为 1。我获得了有关外观的文档:

/api/workspaces/:workspace_id/tasks?filter[]=is_done is false&filter[]=external_reference starts with /

如何在同一个 GET 中组合 2 次相同的查询变量(过滤器)?

我试过了:

def JSONArray tasks = liquidPlanner.get( path: 'workspaces/'+LP_WORKSPACE_ID+'/tasks', query: ['filter[]':'external_reference contains /', 'filter[]':'is_done is false'] );

但这不起作用。

问候,

维姆

【问题讨论】:

    标签: groovy httpbuilder


    【解决方案1】:

    尝试以下方法:

    def JSONArray tasks = liquidPlanner.get( 
      path: 'workspaces/'+LP_WORKSPACE_ID+'/tasks', 
      query: ['filter[]':['external_reference contains /', 'is_done is false']] 
    );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-07
      • 2023-03-29
      • 2015-10-11
      • 1970-01-01
      相关资源
      最近更新 更多