How to do a GET with multiple times the same parameters using httpbuilder and groovy?

StackOverflow https://stackoverflow.com/questions/7505923

  •  25-01-2021
  •  | 
  •  

Question

I am using Groovy 1.8 and HttpBuilder 0.5.1 to talk to a REST webinterface. I have this working:

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 /'] );

I need to combine those 2 into 1. I got this documentation on how it should look:

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

How do I combine 2 times the same query variable (filter) in the same GET ?

I tried this:

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

but that does not work.

regards,

Wim

Was it helpful?

Solution

Try the following:

def JSONArray tasks = liquidPlanner.get( 
  path: 'workspaces/'+LP_WORKSPACE_ID+'/tasks', 
  query: ['filter[]':['external_reference contains /', 'is_done is false']] 
);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top