Is it possible to return a CustomMetaData in a @HttpGet?
Is it possible to return a CustomMetaData? I'm getting the error "HttpGet methods do not support return type of InsPackages.Wrapper" when I added "customMetadata" codes on my class. Here's my code:
@RestResource(urlMapping='/api/PackageLicense')
global with sharing class InsPackages{
@HttpGet
global static Wrapper doGet(){
Wrapper wrap = new Wrapper();
List<PackageLicense> packageList = [SELECT NamespacePrefix, Status, CreatedDate, LastModifiedDate FROM PackageLicense];
List<Publisher> publisherList = [SELECT Name, MajorVersion, MinorVersion, NamespacePrefix FROM Publisher];
Metadata.CustomMetadata customMetadata = new Metadata.CustomMetadata();
Metadata.CustomMetadataValue customField = new Metadata.CustomMetadataValue();
for(PackageLicense p : packageList){
customField.field = 'NamespacePrefix';
customField.value = p.NamespacePrefix;
customMetadata.values.add(customField);
}
wrap.customMetadata = customMetadata;
return wrap;
}
global class Wrapper{
public List<Metadata.CustomMetadataValue> customMetadata {get; set;}
}
}
@RestResource(urlMapping='/api/PackageLicense')
global with sharing class InsPackages{
@HttpGet
global static Wrapper doGet(){
Wrapper wrap = new Wrapper();
List<PackageLicense> packageList = [SELECT NamespacePrefix, Status, CreatedDate, LastModifiedDate FROM PackageLicense];
List<Publisher> publisherList = [SELECT Name, MajorVersion, MinorVersion, NamespacePrefix FROM Publisher];
Metadata.CustomMetadata customMetadata = new Metadata.CustomMetadata();
Metadata.CustomMetadataValue customField = new Metadata.CustomMetadataValue();
for(PackageLicense p : packageList){
customField.field = 'NamespacePrefix';
customField.value = p.NamespacePrefix;
customMetadata.values.add(customField);
}
wrap.customMetadata = customMetadata;
return wrap;
}
global class Wrapper{
public List<Metadata.CustomMetadataValue> customMetadata {get; set;}
}
}
Комментарии
Отправить комментарий