Searching with Custom Fields using the Ruby Gem

I’m working with the Ruby Gem and having a lot of trouble turning the documentation into code. I am trying to search for tasks in a workspace where a custom field has a specific value. I have tried variations of:

@asana.tasks.search_tasks_for_workspace(workspace_gid: “workspace_gid” , options: { “custom_fields.custom_field_gid.value” : “Sara” } ) and always receive:

Asana::Errors::InvalidRequest: You must specify at least one search filter.

I have tried moving the custom field specification outside of options, as well as inside of params inside options. What is the proper way to do this?

I’ll try to help, even if I never did any ruby programming!

copy-paste based on documentation:

result = client.tasks.search_tasks_for_workspace(workspace_gid: xxxxxxxxx,
custom_fields.yyyyyy.value: “Sara”)

I don’t think that the search criteria goes in the “options” as you did, but directly in the “root” function parameter.

I suppose that, in your example, “workspace_gid” and “custom_field_gid” are not as-is, they are replaced by gid of your custom field and workspace?

Hope this works!

Thanks @Frederic_Malenfant for providing assistance.

@Sara_Tibbetts Hopefully Frederic’s response helps solve the matter.

@Frederic_Malenfant @Rashad_Issa hat doesn’t seem to work because in Ruby that is invalid. That’s why I’ve tried wrapping in double quotes, which also doesn’t work

This is the error when not using quotes:
(eval):2: no . floating literal anymore; put 0 before dot

This is with quotes:
ArgumentError: unknown keyword: custom_fields.yyyyyyy.value

Ok, use the double quotes, but as i said, not in the “options” parameter, directly in the same level as your workspace_gid.

Doing so I get: ArgumentError: unknown keyword: custom_fields.yyyyyyy.value

1 Like

Sorry you are still having troubles with this.

Bringing in some gurus to see if anyone else has experience in the same area.

@Bastien_Siebman @Julien_RENAUD @lpb @Phil_Seeman @Paul_Grobler @Jerod_Hillard @Matt_Dickinson @Emily_Roman

@Rashad_Issa I’m honored that you would think I know anything about APIs :wink: I’m going to fade to black and let the professionals handle this one.


hahahahaha I am right there in the dark with you mate!! not the only one LOL



I’ve never done any Ruby programming but why let that stop me here!

Seriously, just a long shot, but is there any chance that custom_fields is an array and that you’d need something more like custom_fields[custom_field_gid].value?

Please don’t waste more than a moment on that because it’s really just a shot in the dark.


1 Like

My advice would be to use Postman for example to run the request there first, and once you are sure the request format and params are correct, try to migrate it into your code…