You need to sign in to do that
Don't have an account?
Mads Peter Rommedahl
POST request from Postman seems to ignore @HttpPost annotation
Hey all, I'm making a callback Apex class that's supposed to act differently depending on whether it gets a GET call or a POST call to a specific endpoint. The callback class has two exposed methods, doGet() and doPost() annotated with @HttpGet and @HttpPost respectively like this:
@RestResource(urlMapping='/inMobileCallback') global with sharing class InMobileCallback {
@HttpGet
global static void doGet() {
// Logic
}
@HttpPost
global static void doPost(){
// logic
}
But when I try to make a POST request to the designated REST endpoint using Postman (https://www.getpostman.com/), I get a 500 response (with or without a body):
and from looking in my custom Apex Errors Report I can see that this is due to it trying to run the doGet() (which, naturally, fails due to there being none of the expected GET parameters):
So, basically, what is happening is that despite explicitly sending a POST request, Salesforce runs the doGet() instead of doPost(). Since doGet() is the first method in the class, my guess is that either it's somehow just ignoring the annotations altogether or it misinterprets the POST request from Postman as a GET request... regardless, I'm thoroughly confused by this. Have anyone seen anything like this?
@RestResource(urlMapping='/inMobileCallback') global with sharing class InMobileCallback {
@HttpGet
global static void doGet() {
// Logic
}
@HttpPost
global static void doPost(){
// logic
}
But when I try to make a POST request to the designated REST endpoint using Postman (https://www.getpostman.com/), I get a 500 response (with or without a body):
and from looking in my custom Apex Errors Report I can see that this is due to it trying to run the doGet() (which, naturally, fails due to there being none of the expected GET parameters):
So, basically, what is happening is that despite explicitly sending a POST request, Salesforce runs the doGet() instead of doPost(). Since doGet() is the first method in the class, my guess is that either it's somehow just ignoring the annotations altogether or it misinterprets the POST request from Postman as a GET request... regardless, I'm thoroughly confused by this. Have anyone seen anything like this?
cipto cipto
I'm having the same issue. No resolution?