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

Why is meta update throwing exception?

Why the code throws "null: Must specify a deployment status for the Custom Object"?

 CustomObject co = new CustomObject();
            String name = "MyCustomObject";
            co.fullName = (name + "__c");
            co.deploymentStatus = (DeploymentStatus.InDevelopment);
            co.description = ("Created by the Metadata API");
            co.enableActivities = (true);
            co.label = (name + " Object");
            co.pluralLabel = (co.label + "s");
            co.sharingModel = (SharingModel.ReadWrite);

            CustomField nf = new CustomField();
            nf.type = (FieldType.Text);
            nf.label = (co.fullName + " Name");

            co.nameField = (nf);

            UpdateMetadata updateMetadata = new UpdateMetadata();
            updateMetadata.metadata = (co);
            updateMetadata.currentName = co.fullName;

            AsyncResult[] ars = ms.update(new UpdateMetadata[] { updateMetadata });

 This is simply translation from Java on

You probably need to add co.deploymentStatusSpecified = true to tell .NET to serialize your deploymentStatus value.
It works works works :D