Wim Deblauwe
Wim Deblauwe

Reputation: 26858

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

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

Upvotes: 0

Views: 1002

Answers (1)

John Wagenleitner
John Wagenleitner

Reputation: 11035

Try the following:

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

Upvotes: 2

Related Questions