Custom field error

const customFieldMap = {
  campaign_id_tru: "1209823194720112", // ← Replace with actual GID
  spend_tru: "1209800151523323", // ← Replace with actual GID
  ad_banner_tru: "1209800282203559", // ← Replace with actual GID
};

// 1. Map of banner names to enum GIDs
const bannerEnumMap = {
  sobeys: "1210109792957782",
  safeway: "1210109907027080",
  voila: "1210109922414540",
  iga: "1210109922897359",
  freshco: "1210109802116595",
  foodland: "1210109803158395",
  "thrifty-foods": "1210109917266071",
  "chalo-freshco": "1210109805605272",
};

// 2. Convert banner string to array of enum GIDs
const bannerNames = inputData.ad_banner_tru
  .toLowerCase()
  .split("-")
  .map((b) => b.trim())
  .filter(Boolean);

//
//GET the GIT values

  //  https://app.asana.com/api/1.0/custom_fields/1209800282203559
const bannerGids = bannerNames.map((b) => bannerEnumMap[b]).filter(Boolean); // remove undefined (invalid names)

console.log("bannerGids:", bannerGids);

// 🧱 3. Build custom_fields with correct multi-enum format
const customFieldsPayload = {
  1209823194720112: campaignIdTru,
  1209800151523323: spendVal,
  1209800282203559: bannerGids, // ✅ CORRECT FORMAT
};

// 🚀 4. Create the task
const newTaskBody = {
  name: inputData.campaign_name_tru,
  notes: "Auto-generated campaign task",
  projects: [asanaProjectId],
  custom_fields: customFieldsPayload,
};

console.log("data to be send :", newTaskBody);

const createdTaskResponse = await fetch(
  "https://app.asana.com/api/1.0/tasks",
  {
    method: "POST",
    headers,
    body: JSON.stringify({ data: newTaskBody }),
  }
);

const createdTaskData = await createdTaskResponse.json();
console.log("createdTaskData:", createdTaskData);

And the Error I got is

Failed to create new task: [
{
message: ‘multi_enum_values: [0]: Not the correct type’,
help: 'For more information on API status codes and how to handle them, read the docs
},
{
message: ‘multi_enum_values: [1]: Not the correct type’,
help: 'For more information on API status codes and how to handle them, read the docs
},
{
message: ‘multi_enum_values: [2]: Not the correct type’,
help: 'For more information on API status codes and how to handle them, read the docs
},
{
message: ‘multi_enum_values: [3]: Not the correct type’,
help: 'For more information on API status codes and how to handle them, read the docs
}
]

Confused how to send data in custom field

A couple of things to note:

Your custom field gids all need to be strings; currently they are numeric (no quotes around them).

Your multi_enum field data is clearly not in the right format - the errors are telling you that - but you don’t show the contents of bannerGids so we can’t tell exactly what’s wrong about them. Perhaps the same issue of numeric vs string? Your multi_enum values must look like this:

       "custom_fields": {
            "1202241367094442": ["120224049594443","1207277200442900"]
        }
1 Like