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
jwillansjwillans 

Metadata - getting diagnostics

We're experiencing some unexpected behaviour with the metadata API and would like to get some diagnostics on calls to the API which are evaluated asynchronously. Here is a sample of the code we are using to do this:

AsyncResult[] result = binding.create(metadata);
for(int z=0;z
AsyncResult r = result[z];
AsyncRequestState state = r.getState();
while(state.equals(state.InProgress)) {
System.out.println("Seconds: " + r.getSecondsToWait());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
state = r.getState();
} System.out.println("Status: " + r.getStatusCode());

The issue is that the transaction seemingly never completes, it remains in the InProgress state with 10 seconds remaining and never exits the loop. Could someone give me a sample example of how errors should be extracted from metadata calls in this way?

Thanks,

James
Bill EidsonBill Eidson
This appears to be a service problem... the asynchronous work should complete relatively quickly.  A bug has been filed for this issue.  I'll post another response once the issue has been resolved.

  Thanks,

  - Bill
SteveBowerSteveBower
This is a drive-by random comment after ten seconds of eyeballing:

Should this:

while(state.equals(state.InProgress)) {


be this:

while(state.equals(AsyncRequestState.InProgress)) {

jwillansjwillans
Steve - Thanks for the suggestion, but this does not solve the problem. I think it may be a service issue as Bill suggests.

James
Bill EidsonBill Eidson
Ok, please contact me via private message w/ contact info -- I'll need to gather some more information to track this issue down.
rajanrajan

Hi Bill can you provide me the code example of Deploy and Retrieve Metadata API Calls in .Net. I will be really thanks full to you.



Bill EidsonBill Eidson
Rajan -

  We have not yet written any metadata API examples using .Net, and I'm personally not familiar with .Net (am using Linux).  However, usually translating Java to C# is relatively straightforward, and our docs have examples using Java.  If you have any problems or issues getting things to work with .Net, feel free to post a follow up (or contact me with a message) & I'll try to answer your questions or find someone who can.

  Thanks,

  - Bill
MaxFrielMaxFriel

I believe I am seeing a similar problem, here is the code...

public RetrieveResult retrieve(RetrieveRequest req){
        RetrieveResult ret = null;
        try{
            AsyncResult asyncResult = metaConn.retrieve(req);
            long wait = 1;
            while(asyncResult != null && !asyncResult.isDone() && asyncResult.getState() != AsyncRequestState.Error){
                Thread.sleep(wait * 1000);
                wait *= 2;
                System.out.println("Wait time:" + wait + " State:" + asyncResult.getState().toString());
            }
           
            ret = metaConn.checkRetrieveStatus(asyncResult.getId());
        }catch(Exception e){
            e.printStackTrace();
        }
        return ret;
    }

 

And here is the output so far...

Wait time:2 State:InProgress
Wait time:4 State:InProgress
Wait time:8 State:InProgress
Wait time:16 State:InProgress
Wait time:32 State:InProgress
Wait time:64 State:InProgress
Wait time:128 State:InProgress
Wait time:256 State:InProgress
Wait time:512 State:InProgress
Wait time:1024 State:InProgress

Wait time:2048 State:InProgress

 

Here is the toString output of the PackageTypeMembers that are in the Package that was included in the RetrieveRequest...

[PackageTypeMembers  members='{[1]PersonAccount-US_CONTACT,}'
 name='Layout'
]

[PackageTypeMembers  members='{[2]MigrateMe,VOMTest,}'
 name='ApexClass'
]

[PackageTypeMembers  members='{[21]ReadOnly,Standard,z_Specialty Sales Manager - Platform,GDO_Requirement_Admin,CN_SALES_PLACEHOLDER,z_Primary Care Sales Management - Platform,GDO_Requirement_Read Only,ContractManager,z_Managed Markets Sales - Platform,SolutionManager,Admin,StandardAul,z_Specialty Sales - Platform,StandardAul1,MarketingProfile,z_MSL Director - Platform,GDO_Requirement_Admin_EMBU,z_Primary Care Sales - Platform,z_Managed Markets Director - Platform,GDO_CM_Manager,z_MSL - Platform,}'
 name='Profile'
]

 

So it isn't a ton of information being pulled down. 

 

I am not entriely sure the RetrieveRequest was formed correctly, but shouldn't it error out at some point if it wasn't?