I am using Rest API to update the Apex trigger using ApexTriggerMember. I am using the below json string as body in request.
String json = {"MetadataContainerId" : "1dc7F00000DD9UYQA1", "FullName" : "Suggestion__c" , "Body": "{"Name":"RSLC_Suggestion","Body":"trigger RSLC_Suggestion on Suggestion__c (before insert, before update, after insert, after update){ \n if(trigger.isAfter && (trigger.isInsert || trigger.isUpdate || trigger.isDelete) )\n { \n RollUpSummaryGenerator.associationOdChildRecordsToParentRecords(trigger.new,'Suggestion','SuggestionNumber','Contact','SuggestioNumbers'); \n } \n}","tableEnumOrId":"Suggestion__c"}"}
I am receiving the below response
String response = "[{"message":"No such column 'MetadataContainerId' on sobject of type ApexTrigger","errorCode":"INVALID_FIELD"}]"
Can anyone take a look at this issue?
public static void createApexTriggerMember(String metadataContainerId, String apexClassId, string classBody)
{
// String body = '{"MetadataContainerId" : "'+metadataContainerId+'", "ContentEntityId" : "'+apexClassId+'", "FullName" : "'+'\'Suggestion__c\' , "Body": "'+classBody+'"}';
String body = '{"MetadataContainerId" : "'+metadataContainerId+'", "FullName" : "'+'Suggestion__c" , "Body": "'+classBody+'"}';
Http objHTTP = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:Tooling_API_Credential/services/data/v44.0/tooling/sobjects/ApexTriggerMember');
req.setBody(body);
req.setMethod('POST');
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
req.setHeader('Content-Type', 'application/json');
Http h = new Http();
String response = h.send(req).getBody();
System.debug('response= '+response);
Map<String,Object> rmp = (Map<String,Object>)JSON.deserializeuntyped(response);
String apmid = (String)rmp.get('id');
// createContainerAsyncRequest(metadataContainerId);
}
I am getting an additional error as below:
{"message":"Unexpected character ('N' (code 78)): was expecting comma to separate OBJECT entries at [line:1, column:15]","errorCode":"JSON_PARSER_ERROR"}
Is there no one in this salesforce ecosystem who can help me out?
I tried correcting my json. Now I am receiving the below error.
DEBUG|response= [{"message":"No such column 'ContentEntityId ' on sobject of type ApexTriggerMember","errorCode":"INVALID_FIELD"}]