I was trying to invoke metadata api from apex. Link provides an excellent way to do that.
I did generate the Apex Class and now as per the post's code when i run that code it should create an object on the fly, callout happened Succesfully ( when i ran in developer console logs showed success ). But its not reflected even after couple of hours.
Did i miss anything?
Best Answer
The Salesforce Metadata API is asynchronous. Meaning you do not get an immediate, yes/no, answer from it. You need to call the checkStatus operation to poll for the result, as described here.
If your using the API with Apex, you must poll for it rather than using a loop (as Apex does not have the concept of pausing the execution for duration). You can either use apex:actionPoller (Visualforce) or Batch Apex. The library you have linked to gives examples of each described in the read me file.
Here is an example from the Apex Metadata library submitting the Metadata creations via Batch Apex and having it poll those operations, submitting an email (action configurable) to the user with the results.