I am trying to implement a webhook from a 3rd party application (Eventbrite) using a Custom REST API in Salesforce.The issue here is that 3rd party API uses "Accept: text/plain" parameter in their Request Header and because of that Apex REST API rejects all inbound api request with below error.
[{"errorCode":"NOT_ACCEPTABLE","message":"Accept header specified in HTTP request is not supported: text/plain"}]
I have checked in the 3rd party application (Eventbrite) docs and it seems like we cannot change the format of the request . As per Salesforce documentation, it only supports Support for JSON and XML as HTTP ACCEPT header.
I am just wondering , is there any way to support "text/plain " as Accept header ?
Request Header from Eventbrite Webhook
Request Headers
X-Eventbrite-Event: test
Accept: text/plain
X-Eventbrite-Delivery: 1078584
User-Agent: Eventbrite Hookshot 91008c8
Content-type: application/json
User-ID-Sender: 106077679079
[EDIT] :Here is the code snippet I am using
@HttpPost
global static String createWebhookRequest()
{
RestRequest request = RestContext.request;
Webhook__c hook= new Webhook__c(
Message__c = request.requestBody.toString());
insert hook;
return String.valueOf(hook.id);
}
Here is the documentation I am referring to . https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_rest_resources.htm
Is there a possible workaround to this issue?