2

I'm trying to use readMetadata in the metadata API to download various things about an org. This works great for most everything but base64 values are always truncated..

Here's my test aura component:

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing 
        elit, sed do eiusmod tempor incididunt ut labore 
        et dolore magna aliqua. Ut enim ad minim veniam, quis 
        nostrud exercitation ullamco laboris nisi ut aliquip 
        ex ea commodo consequat. Duis aute irure dolor in 
        reprehenderit in voluptate velit esse cillum dolore eu 
        fugiat nulla pariatur. Excepteur sint occaecat 
        cupidatat non proident, sunt in culpa qui officia 
        deserunt mollit anim id est laborum.</p>
</aura:component>

Here's a request I send to soapui to test:

<soapenv:Envelope ...>
   <soapenv:Header>
      <met:SessionHeader>
         <met:sessionId>yadda.yadda</met:sessionId>
      </met:SessionHeader>
   </soapenv:Header>
    <soapenv:Body>
        <met:readMetadata>
            <met:type>AuraDefinitionBundle</met:type>
            <met:fullNames>MetadataApiTest</met:fullNames>
        </met:readMetadata>
    </soapenv:Body>
</soapenv:Envelope>

The response:

<soapenv:Envelope ...>
   <soapenv:Body>
      <readMetadataResponse>
         <result>
            <records xsi:type="AuraDefinitionBundle">
               <fullName>MetadataApiTest</fullName>
               <apiVersion>52.0</apiVersion>
               <auraDefinitions>
                  <auraDefinition>
                     <defType>1(db=1,api=CONTROLLER)</defType>
                     <source>KHsKCW15QWN0aW9uIDogZnVuY3Rpb24oY29tcG9uZW50LCBldmVudCwgaGVscGVyKSAKICAgIHsKICAgICAgICB2YXIgeCA9IDE7CiAgICAgICAgeCsrOyB4Kys7IHgrKzsgeCsrOyB4Kys7IHgrKzsgeCsrOyB4Kys7IHgrKzsgeCsrOyAKICAgICAgICB4Kys7IHgrKzsgeCsrOyB4Kys7IHgrKzsgeCsrOyB4Kys7IHgrKzsgeCsrOyB4Kys7IAogICAgICAgIHgrKzsgeCsrOyB4Kys7IHgrKzsgeCsrOyB4Kys7IHgrKzsgeCsrOyB4Kys7IHgrKzsgCiAg</source>
                  </auraDefinition>
                  <auraDefinition>
                     <defType>2(db=2,api=COMPONENT)</defType>
                     <source>PGF1cmE6Y29tcG9uZW50IGltcGxlbWVudHM9ImZsZXhpcGFnZTphdmFpbGFibGVGb3JSZWNvcmRIb21lLGZvcmNlOmhhc1JlY29yZElkIiBhY2Nlc3M9Imdsb2JhbCIgPgoJPHA+TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgCiAgICAgICAgZWxpdCwgc2VkIGRvIGVpdXNtb2QgdGVtcG9yIGluY2lkaWR1bnQgdXQgbGFib3JlIAogICAgICAgIGV0IGRvbG9yZSBtYWduYSBhbGlxdWEuIFV0IGVuaW0gYWQg</source>
                  </auraDefinition>
               </auraDefinitions>
               <controllerContent>KHsKCW15QWN0aW9uIDogZnVuY3Rpb24oY29tcG9uZW50LCBldmVudCwgaGVscGVyKSAKICAgIHsKICAgICAgICB2YXIgeCA9IDE7CiAgICAgICAgeCsrOyB4Kys7IHgrKzsgeCsrOyB4Kys7IHgrKzsgeCsrOyB4Kys7IHgrKzsgeCsrOyAKICAgICAgICB4Kys7IHgrKzsgeCsrOyB4Kys7IHgrKzsgeCsrOyB4Kys7IHgrKzsgeCsrOyB4Kys7IAogICAgICAgIHgrKzsgeCsrOyB4Kys7IHgrKzsgeCsrOyB4Kys7IHgrKzsgeCsrOyB4Kys7IHgrKzsgCiAg</controllerContent>
               <description>here is a description.</description>
               <markup>PGF1cmE6Y29tcG9uZW50IGltcGxlbWVudHM9ImZsZXhpcGFnZTphdmFpbGFibGVGb3JSZWNvcmRIb21lLGZvcmNlOmhhc1JlY29yZElkIiBhY2Nlc3M9Imdsb2JhbCIgPgoJPHA+TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgCiAgICAgICAgZWxpdCwgc2VkIGRvIGVpdXNtb2QgdGVtcG9yIGluY2lkaWR1bnQgdXQgbGFib3JlIAogICAgICAgIGV0IGRvbG9yZSBtYWduYSBhbGlxdWEuIFV0IGVuaW0gYWQg</markup>
               <type>Component</type>
            </records>
         </result>
      </readMetadataResponse>
   </soapenv:Body>
</soapenv:Envelope>

When I decode the response, I get only this much:

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing 
        elit, sed do eiusmod tempor incididunt ut labore 
        et dolore magna aliqua. Ut enim ad 

All base64 values that I see get truncated at about this same size (or maybe this exact size - I have not checked).

I see types like profiles having no problem returning 500kb responses, so I don't think it's a size issue.

I'm not using a wsdl - this is building the requests and parsing the responses 'by hand', because I'm a glutton for punishment or something. Everything else works and the base64 responses are short but look fine otherwise.

Any help?

7
  • Please edit your question and provide a Minimal, Reproducible Example that shows the entire sequence of setting up your test and then performing your test.
    – identigral
    Commented Jun 23, 2021 at 18:35
  • @identigral, I included the sample aura component and the soap ui request that i used to reproduce this problem. If you can't plug these straight into salesforce and soap ui, please let me know. Commented Jun 23, 2021 at 20:28
  • How did you create your Aura component?
    – identigral
    Commented Jun 23, 2021 at 20:50
  • i've seen this issue on components created with dev console and welkin - any method will work fine.. the component works as-expected and my question is about using the metadata api to retrieve it. Commented Jun 23, 2021 at 20:56
  • ....if you try to create this component via Dev Console, you'd get an error message.
    – identigral
    Commented Jun 23, 2021 at 20:58

1 Answer 1

1

I stumbled across this looking for an answer and did some investigation. It looks like that for both AuraDefinitionBundle and LightningComponentBundle the behaviour is the same, readMetadata does indeed appear to truncate the source property at 255 (base64) characters, which I am assuming is undocumented, but default behaviour as a way of limiting response payload sizes. I worked around this by doing a further query to the tooling objects AuraDefinition and LightningComponentResource, to retrieve the full source in text format e.g.

SELECT DefType, Source FROM AuraDefinition WHERE AuraDefinitionBundleId WHERE Id = '0Abam000000tvUpCAI'

or for LightningComponentBundle:

SELECT FilePath, Source FROM LightningComponentResource WHERE LightningComponentBundleId = '0Rbam000001SKWICA4'

Hope it helps someone.

2
  • TY for the reply! I did eventually get it to work and am looking at that code now and, tbh, am not sure what I did to finally make it work.. There was something different about requests that return a zip response, maybe? I can dig into it if someone's stuck here.. Commented Jul 9 at 14:16
  • I'm not blocked as I use the workaround above, however if you do figure out what you did it would be really good to know, especially if there's a better way 👍 Commented Jul 9 at 14:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .