6

While deploying code by ANT, i am receiving following error for all Static Resources:

  1. staticresources/myResource.resource-meta.xml -- Error: Required field is missing: content

Could this be related to API Version? Never got this kind of error in earlier deployments.

Following is the xml file content:

<?xml version="1.0" encoding="UTF-8"?>
<StaticResource xmlns="http://soap.sforce.com/2006/04/metadata">
     <cacheControl>Public</cacheControl>
     <contentType>text/xml</contentType>
</StaticResource>
1

When you deploy your static resources from ANT tool you need to send .xml file also in below format for every static resource :

  1. If static resource is of type zip:

<?xml version="1.0" encoding="UTF-8"?> <StaticResource xmlns="http://soap.sforce.com/2006/04/metadata"> <cacheControl>Public</cacheControl> <contentType>application/octet-stream</contentType> </StaticResource>

  1. If static resource of type any other then:

<?xml version="1.0" encoding="UTF-8"?> <StaticResource xmlns="http://soap.sforce.com/2006/04/metadata"> <cacheControl>Private</cacheControl> <contentType>application/javascript</contentType> </StaticResource>

Here content type is the type of the file

Hope this will help you :)

Ask me if you need any more help

|improve this answer|||||
  • The error comes because of xml file, and the sample code in the question contains the properties cacheControl and contentType. Not sure whats missing.. – San Tosh Jan 27 '16 at 10:53
  • @SanTosh Any clue for the issue, you were facing. I am facing similar issue. – sakura Jun 18 '16 at 11:44
1

hey guys i was facing same problem when i tried deploying the staticresources. and i solved with adding blank content tag as following :

<?xml version="1.0" encoding="UTF-8"?>
<StaticResource xmlns="http://soap.sforce.com/2006/04/metadata">
     <cacheControl>Public</cacheControl>
     <contentType>application/xml</contentType>
     <content></content>
</StaticResource>

and it worked for me. hope this will help you.

|improve this answer|||||
1

This error Required field is missing: content generally come when content file is missing in the folder. So when ever we deploy any content on salesforce and we have only meta.xml file not the actual content file then need to make sure that we have created the respective content file.

Like for staticresorces -> .resource file, Apex class -> .cls file, Visualforce page -> .page file etc.

Example : Error: staticresources/myResource.resource-meta.xml(myResource):Required field is missing: content

Then your content file "myResource.resource" is missing in staticresources folder. Create the file named as "myResource.resource".

Then again start the build.

This worked for me. Hope this will help you.

|improve this answer|||||
0

Make sure your directory structure and filenames are right. This is what worked for me:

package.xml in the main directory:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
  <types>
    <members>*</members>
    <name>StaticResource</name>
  </types>
  <version>40.0</version>
</Package>

The zip needs to be called my_archive.resource not .zip and needs to be in the staticresources directory.

Then you need to have a file staticresources/my_archive.resource-meta.xml with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<StaticResource xmlns="http://soap.sforce.com/2006/04/metadata">
  <cacheControl>Private</cacheControl>
  <contentType>application/zip</contentType> 
</StaticResource>

With all this, ant deploy should work. This is not obvious at all and it's really hard to find in official docs.

To point to a file from your zip, in a VisualForce page, use something like:

<img src="{!URLFOR($Resource.my_archive, 'my_image.png')}"/>
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.