Hi,
Make sure you are using correct API.
EntityDefinitions(LogicalName='account')/Attributes(LogicalName='statuscode')/Microsoft.Dynamics.CRM.StatusAttributeMetadata?$select=LogicalName&$expand=OptionSet($select=Options)
Based on your field schema name you would need to change your API URL. See below logic.
if (name1 == "'statecode'")
ServiceUrl = apiUrl + "/EntityDefinitions(LogicalName=" + name + ")/Attributes(LogicalName=" + name1 + ")/Microsoft.Dynamics.CRM.StateAttributeMetadata?$select=LogicalName&$expand=OptionSet($select=Options)";
else if (name1 == "'statuscode'")
ServiceUrl = apiUrl + "/EntityDefinitions(LogicalName=" + name + ")/Attributes(LogicalName=" + name1 + ")/Microsoft.Dynamics.CRM.StatusAttributeMetadata?$select=LogicalName&$expand=OptionSet($select=Options)";
else
ServiceUrl = apiUrl + "/EntityDefinitions(LogicalName=" + name + ")/Attributes(LogicalName=" + name1 + ")/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet($select=Options)";
This code will work only for Local Optionset but not for Global Optionset.
For Global Optionset you should look at below link,.
If the attribute used a global optionset, the GlobalOptionSet property would contain the defined options and the OptionSet property would be null.
Please mark my answer verified if i were helpful