API Project update is not working

Hi there,

I would like to update a particular project using the API (Python).
I have tried to run the API call as specified below and the code runs without errors. However, the specified field is not updated.
Anyone who experienced the same problem. Would appreciate a code (obviously without the credentials & IDs) that worked. My guess is that I have the error in my body definition.
Thanks in advance.

BR,
Bálint

projects_api_instance = asana.ProjectsApi(api_client)
body = {"data":{"Custom fields":{"Product description [VBGC]": "Hello world,}}}
opts = {"same options as in the official example"}
try:
  # Update a project
  api_response = projects_api_instance.update_project(body,     project_gid,opts=opts)
  pprint(api_response)
except ApiException as e:
  print("Exception when calling ProjectsApi->update_project: %s\n" % e)

Hi @Balint_Biro, and welcome to the forum! :waving_hand:

It looks like the issue is with the request body format. If you check our API Reference and select Shell as the language in the right-hand panel, you’ll see that the custom_fields parameter is expected to be a dictionary, where:

  • The keys are custom field GIDs

  • The values are either strings (for text/number fields) or GIDs (for enum options or other object-based fields)

Here’s a simple example of a valid request body for this endpoint:

{
  "data": {
    "custom_fields": {
      "1234": "Text Value", 
      "4321": "0000"
    }
  }
}

  • "1234" → GID of a text custom field

  • "4321" → GID of an enum custom field, with "0000" being the GID of the selected enum option

If you replace your current request body with this structure (using your actual GIDs), it should work as expected.

Let me know if that helps or if you have any follow-up questions!

Best,
Dominik

1 Like

Hi @dbrdak ,

Thank you so much for the reply. Yeah, now its working fine.

BR,

Bálint