1

Is it possible to create an outbound message using the Tooling API (REST), similar to what's described in here?

According to salesforce Tooling API documentation i tried to create outbound message using following code

 String json = '{"Name":"MyCustomObjectOutboundMessages","fields":
      ["Id","Action__c","Value1__c","Value2__c","sObjectName__c"],"includeSessionId": 
      true, "description": "Outbound message for custom object ","endpointUrl": 
      "https://myend-point.com/listener"}';


Httprequest req = new HttpRequest();
req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v'+METADATA_API_VERSION+'/sobjects/WorkflowOutboundMessage'); 

req.setMethod('POST'); 
req.setHeader('Content-Type', 'application/json');
req.setHeader('Authorization', 'OAuth ' + UserInfo.getSessionId());            
req.setBody(json);

Http httpReq = new Http(); HttpResponse res = httpReq.send(req); 
System.debug(res.getBody());

but it is saying

[{"errorCode":"NOT_FOUND","message":"The requested resource does not exist"}]

1
  • I do not see /tooling in your url
    – Eric
    Commented Jan 29, 2017 at 16:22

1 Answer 1

1

Per your comment here is a working endpoint for a WorkflowOutboundMessage

https://xyz.my.salesforce.com/services/data/v37.0/tooling/sobjects/WorkflowOutboundMessage

Which gets the object description:

{
  "objectDescribe": {
    "activateable": false,
    "createable": true,
    "custom": false,
    "customSetting": false,
    "deletable": true,
    "deprecatedAndHidden": false,
    "feedEnabled": false,
    "keyPrefix": "04k",
    "label": "Workflow Outbound Message",
    "labelPlural": "Workflow Outbound Messages",
    "layoutable": false,
    "mergeable": false,
    "mruEnabled": true,
    "name": "WorkflowOutboundMessage",
    "queryable": true,
    "replicateable": false,
    "retrieveable": true,
    "searchable": true,
    "triggerable": false,
    "undeletable": false,
    "updateable": true,
    "urls": {
      "rowTemplate": "/services/data/v37.0/tooling/sobjects/WorkflowOutboundMessage/{ID}",
      "defaultValues": "/services/data/v37.0/tooling/sobjects/WorkflowOutboundMessage/defaultValues?recordTypeId&fields",
      "describe": "/services/data/v37.0/tooling/sobjects/WorkflowOutboundMessage/describe",
      "sobject": "/services/data/v37.0/tooling/sobjects/WorkflowOutboundMessage"
    }
  },
  "recentItems": []
}

Yes. I find that the documentation holds a lot of answers....

Tooling API Workflow Rule:

Represents a workflow rule that is used to fire off a specific workflow action when the specified criteria is met. Includes access to the associated WorkflowRule object in Salesforce Metadata API.

Available from API version 30.0 or later.

Supported SOAP Calls
create(), delete(), query(), retrieve(),search(), update(), upsert()

Supported REST HTTP Methods
Query, DELETE, GET, PATCH, POST

https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_workflowrule.htm

WorkflowOutboundMessage

Represents an outbound message. An outbound message sends information to a designated endpoint, like an external service. Outbound messages are configured from Setup. You must configure the external endpoint and create a listener for the messages using the SOAP API. This object is available in API version 32.0 and later.

Supported SOAP Calls
create(), delete(), query(), retrieve(),search(), update(), upsert()

Supported REST HTTP Methods
DELETE, GET, PATCH, POST

https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_workflowoutboundmessage.htm

2
  • I tried creating outbound message by following documentation, But it is failing with [{"errorCode":"NOT_FOUND","message":"The requested resource does not exist"}] Commented Jan 29, 2017 at 11:42
  • @Sujithkandamuri - see my updated answer
    – Eric
    Commented Jan 29, 2017 at 16:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .