I am creating a KAV article using Apex code. One of fields is a file field, and I set the various fields within there: Name, Content Type, and Body. It appears that I have to set the Content Type when doing this from Apex (unlike from doing it from the UI), if I try not to set it I get this error:
FIELD_INTEGRITY_EXCEPTION, Name, ContentType are required if Body is specified
Now the issue is that when I try and set the Content Type, some values throw errors. For example, if I try and set Content Type to “text/javascript”, I get the error:
bad value for restricted picklist field: text/javascript
So my question is, are the valid picklist values for Content Type documented anywhere?
Answer
I was able to get the values using Describe methods, as discussed in this post:
how to get a picklist all values in apex controller
From this, I was able to figure out the list, which I will paste here if anyone else is interested.
application/html
application/java-archive
application/javascript
application/msword
application/octet-stream
application/octet-stream;type=unknown
application/opx
application/pdf
application/postscript
application/rtf
application/vnd.google-apps.document
application/vnd.google-apps.drawing
application/vnd.google-apps.form
application/vnd.google-apps.presentation
application/vnd.google-apps.script
application/vnd.google-apps.spreadsheet
application/vnd.ms-excel
application/vnd.ms-excel.sheet.macroEnabled.12
application/vnd.ms-infopath
application/vnd.ms-powerpoint
application/vnd.ms-powerpoint.presentation.macroEnabled.12
application/vnd.ms-word.document.macroEnabled.12
application/vnd.oasis.opendocument.presentation
application/vnd.oasis.opendocument.spreadsheet
application/vnd.oasis.opendocument.text
application/vnd.openxmlformats-officedocument.presentationml.presentation
application/vnd.openxmlformats-officedocument.presentationml.slideshow
application/vnd.openxmlformats-officedocument.presentationml.template
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
application/vnd.openxmlformats-officedocument.spreadsheetml.template
application/vnd.openxmlformats-officedocument.wordprocessingml.document
application/vnd.openxmlformats-officedocument.wordprocessingml.template
application/vnd.visio
application/x-gzip
application/x-java-source
application/x-javascript
application/x-shockwave-flash
application/x-sql
application/x-zip-compressed
application/xhtml+xml
application/xml
application/zip
audio/mp4
audio/mpeg
audio/x-aac
audio/x-ms-wma
audio/x-ms-wmv
audio/x-wav
image/bmp
image/gif
image/jpeg
image/png
image/svg+xml
image/tiff
image/vnd.adobe.photoshop
image/vnd.dwg
image/x-photoshop
message/rfc822
text/css
text/csv
text/html
text/plain
text/rtf
text/snote
text/stypi
text/webviewhtml
text/x-c
text/x-c++
text/xml
video/mp4
video/mpeg
video/quicktime
video/x-m4v
video/x-ms-asf
video/x-msvideo
Attribution
Source : Link , Question Author : hamayoun , Answer Author : Community