function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
D J RobertsD J Roberts 

Consume x-www-form-urlencoded in HttpPost Request

Really odd thing happening here. 

1. We are trying to consume a HTTP Request from a vendor. They are sending a POST Request to an APEX method hosted on a Salesforce Site Page. The format they are sending it in is the following 
 
https://sandbox.mysalesforceinstance.force.com/mysite/services/apexrest/myapexClass?key1=value1&key2=value2&key3=value3
Here is the Apex for our class: 
 
@RestResource(urlMapping='/myapexClass/*')
global without sharing class myApexClass {


	@HttpPost
  	global static String myApexMethod() {

        // Code blocks for using data here. 

}
The issue is that when we have the above format, I can hit the class with Postman and works perfectly. However, if I provide the URL to our vendor they are getting a 200 response, but our method is not running. 

2. This is the weird part. If we add a random parameter so our code looks like this: 
 
@RestResource(urlMapping='/myapexClass/*')
global without sharing class myApexClass {


	@HttpPost
  	global static String myApexMethod( String RandomValue) {

        // Code blocks for using data here. 

}
Suddenly, we can see the endpoint we provdided the vendor receiving responses, but the method DOES NOT run. We can literally see all the values that are passed in the URL because the class is running but the Method is not. 

I have 2 questions: 

1. Is it possible to consume x-www-form-urlencoded POST requests in Salesforce? 

2. Why does the addition of a parameter make it possible for the endpoint, but the class runs and the method DOES NOT. 


If you can help me out, that would be incredible!