function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ariel Berkman 5Ariel Berkman 5 

Metadata API call results in 'INVALID_LOCATOR' error.

Hi,

When using the Metadata API to list all the ApexTrigger files (via the listMetadata() call), we are getting a "MALFORMED_ID: bad id XXXXX" error and then all subsequent requests return a "INVALID_LOCATOR: Retrieve result has been deleted" error.

We've been using this method to list (and then extract data) from the Metadata API for quite some time, from many Orgs, and this is the first time we are seeing this behavior.

We've tried both v34 and v35 of the API.

Any idea what could be causing this error?

Thanks in advance,
Ariel.
pconpcon
Can you please provide the full REST call you are making (including URL and headers)?  Feel free to obfuscate any sensitive information.
Ariel Berkman 5Ariel Berkman 5
Hi,

It's actually a SOAP call via the Metadata API.  The call is to listMetadata(list_metadata_query, api_version_num).  The metadata object we are trying to list is ApexTrigger.

Thanks,
Ariel.

 
Ariel Berkman 5Ariel Berkman 5
Guys, any idea whether this is a known API bug?  Anything we can about it?

Thanks!
pconpcon
When I make the following SOAP request against the MetadataAPI endpoint [1], I get the expected data back.  Can you please provide the SOAP request you are making and the endpoint you are making it against?
 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:met="http://soap.sforce.com/2006/04/metadata">
   <soapenv:Header>
      <met:SessionHeader>
         <met:sessionId>${#Project#sessionid}</met:sessionId>
      </met:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <met:listMetadata>
         <met:queries>
            <met:type>ApexTrigger</met:type>
         </met:queries>
         <met:asOfVersion>35</met:asOfVersion>
      </met:listMetadata>
   </soapenv:Body>
</soapenv:Envelope>

[1] https://cs18-api.salesforce.com/services/Soap/m/35.0
Ariel Berkman 5Ariel Berkman 5
Thanks for your reply pcon.

The response I'm getting is this:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="http://soap.sforce.com/2006/04/metadata"><soapenv:Body>
<soapenv:Fault>
<faultcode>sf:MALFORMED_ID</faultcode>
<faultstring>MALFORMED_ID: bad id xxxxxx__xxxx__c</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

(I manually changed the name to xxxxxx__xxxx__c).

The endpoint I used was https://cs22.salesforce.com/services/Soap/m/35.0

Any idea what could be causing this or what I can do about it?

Thanks,
Ariel.
pconpcon
You still have not provided the request you are sending to the SOAP endpoint.
Ariel Berkman 5Ariel Berkman 5
The request is a copy/paste of what you wrote, with the exception of a different session_id and a different endpoint.
(issued from this commandline: curl --header "Content-Type: text/xml;charset=UTF-8" --header "SOAPAction:urn:listMetadata" --data @req https://cs22.salesforce.com/services/Soap/m/35.0) 
pconpcon
Using the payload an the cURL you provided, it works perfectly for me.  Do you have any additional environments you could try this on?  If you do not, you will probably need to reach out to Salesforce support.  It looks like there is some metadata that is not in a correct state that is causing a reference Id to be incorrect.
Ariel Berkman 5Ariel Berkman 5
Thanks Pcon.

Yes, in fact, we've been using the same code on many environments and that's the only one that's runing into these issues.

I did contact Salesfoce support and they told me to inquire about the problem here... Any idea how I can get them to look into this?  Given that it's only broken for a specific Org (and it's sandbox), I'm quite sure the code isn't the problem...

Thanks again,
Ariel.
pconpcon
I would just re-open the case and point them to this thread.  Mention that it only fails on this specific sandbox and that the MALFORMED_ID error does not make sense in this instance because you are not providing any Id but are only listing metadata.  If they try to close the case push back.
Ariel Berkman 5Ariel Berkman 5
Thanks, i'll give it a try!