Unable to pass in options with Ruby

Hi all,

I’m taking my first steps in the API and trying a couple of things with Ruby which I haven’t used in the last 3+ years so I’m a bit rusty. I’m creating a script that cycles through projects and removes unwanted custom fields. I’m having trouble figuring out how to pass in the custom field that I want to remove as an option.

project_gid=“1202574217132851”

client = Asana::Client.new do |c|
c.authentication :access_token, token
end

client.projects.remove_custom_field_setting_for_project(project_gid: project_gid, options: {custom_field: [‘1193404856761801’] })

And the error I get is:

`rescue in handle’: custom_field: Missing input (Asana::Errors::InvalidRequest)
the server responded with status 400 (Faraday::BadRequestError)

I understand this is telling me my query is written correctly and I’ve looked at Asana but I can’t figure out how to add the data body.

Any tips? Also I’d love it if you could share any resources with Ruby examples.

Thanks

Hi,

I am looking at the API doc and can’t seem to find the endpoint this method would be using. Can you point me to it please?

Hi Bastien,

Do you mean this doc Asana?

Thanks

Thanks, I was unable to find it somehow.

Did you read the source code of the lib? My guess is that the second param should be something else, or named differently. Maybe you can also log what is the call made by the library.

Hi,

Just thought I’d let you know I figured this out. For the ruby API you pass in options like

remove_cus_field = client.projects.remove_custom_field_setting_for_project(project_gid: ‘project_gid’, custom_field: “14916”, options: {pretty: true})

Where custom_field is the param you’re passing in.

2 Likes

@Ian_Grant thanks for posting the solution - as @Bastien_Siebman likes to say, there is a special place in heaven for devs who come back and post solutions to their problems for others to benefit from!

2 Likes