CustomMetadataLoader icon indicating copy to clipboard operation
CustomMetadataLoader copied to clipboard

Getting Field Header error when they match, even with Sample csv

Open rdclk23 opened this issue 3 years ago • 3 comments

Keep getting Header error when field names match. I even created a test Custom Metadata to match the sample csv file in Git. Got this error using sample file from Git: "Header must contain the api names of the fields.
Fields allowed for this type: (DeveloperName, Label, Description, ns1_CountryCode__c, ns1_CountryName__c)
Fields in file header: {Label, ns1__CountryCode__c, ns1__CountryName__c}" sample.csv

rdclk23 avatar Jul 06 '22 14:07 rdclk23

I'm having the same problem as rdclk23.

Error:Header must contain the api names of the fields.
Fields allowed for this type: (DeveloperName, Label, Description, Active__c, Email__c, Notification_Group__c) Fields in file header: {Active__c, Description, Email__c, Label, Notification_Group__c, DeveloperName}

I even copied and pasted the api names from your error message and it still wont work. Local Regional.csv

ajmdesign avatar Jul 21 '22 16:07 ajmdesign

I'm having the same issue: "Header must contain the api names of the fields.
Fields allowed for this type: (DeveloperName, Label, Description, Region__c, Sub_Region__c)
Fields in file header: {Description, Label, Region__c, Sub_Region__c, DeveloperName}"

LinaNakache avatar Aug 18 '22 08:08 LinaNakache

This issue is probably caused by Excel adding hidden characters to the CSV file, such as the UTF byte order mark (BOM).

In the CSVFileUtil Apex class, replacing line 17 with the following worked for me. It removes all non-US-ASCII characters from the input.

String contents = csvFileBody.toString().replaceAll('[^\\x00-\\x7F]', '');

Alternatively, I would experiment with different CSV encoding, or try a different application like LibreOffice.

jp-ed avatar Mar 14 '23 15:03 jp-ed