简体   繁体   中英

How do I use the REST API to update an Apex Trigger?

curl --location --request PUT 'https://ap17.salesforce.com/services/data/v48.0/sobjects/ApexTrigger/01q2x000000YiNcAAK' \
--header 'Authorization: Bearer 00D2....' \
--header 'Content-Type: application/json' \
--data-raw '{
    "Name": "ContactCreateUpdateDeleteApexTrigger",
    "TableEnumOrId": "Contact",
    "Body":"trigger ContactCreateUpdateDeleteApexTrigger on Contact (after update,after insert, after delete) {            String url = '\''https:endpoint.com'\'';         String content = WebhookClass.jsonContent(Trigger.new, Trigger.old,'\''Contact'\'');         WebhookClass.callout(url, content);          }"
    }'

I am getting 200 Response but my triggers are not updated.

Apex class, Apex trigger tables are visible just for reference purposes and backups. What you do is not a simple data manipulation operation, it has to be a proper deployment with compilation, running unit tests, min 75% code coverage... Especially that your endpoint looks like a production.

Check the Tooling API, it's also RESTful. This should be a nice start: https://salesforce.stackexchange.com/q/156221

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM