You need to sign in to do that
Don't have an account?
Rajagopal Akella
Issue with handling POST request on an apex web service exposed through HTTP force.com site
My Salesforce @RestResource class is having three methods to handle PUT, POST, and GET. But when i am trying to invoke POST from external system, GET method is getting invoked.
When i try to invoke PUT and GET, they are getting invoked correctly. The issue is with POST response only. No idea why GET is getting invoked when i try to POST. Below is my class, and i am using POSTMAN to monitor PUT, POST, and GET responses.
This issue is exclusive when we try to attempt to POST using "http". You will not see this issue if you try to POST using "https".
We need to find a solution to this, as my current project needs an end point to POST using only "http".
Any information regarding this is greatly appreciated!
@RestResource(urlMapping='/myapi/IVAPIInterface/*')
global without sharing class REST_IVAPI {
@HttpPost
global static string doPost() {
RestRequest req = RestContext.request;
System.debug('req is---------------------- ' +req);
return 'happy';
}
@HttpPut
global static string doPut() {
RestRequest req = RestContext.request;
System.debug('req is---------------------- ' +req);
return 'Put';
}
@HttpGet
global static string doGet() {
RestRequest req = RestContext.request;
System.debug('req is---------------------- ' +req);
return 'Get';
}
}
When i try to invoke PUT and GET, they are getting invoked correctly. The issue is with POST response only. No idea why GET is getting invoked when i try to POST. Below is my class, and i am using POSTMAN to monitor PUT, POST, and GET responses.
This issue is exclusive when we try to attempt to POST using "http". You will not see this issue if you try to POST using "https".
We need to find a solution to this, as my current project needs an end point to POST using only "http".
Any information regarding this is greatly appreciated!
@RestResource(urlMapping='/myapi/IVAPIInterface/*')
global without sharing class REST_IVAPI {
@HttpPost
global static string doPost() {
RestRequest req = RestContext.request;
System.debug('req is---------------------- ' +req);
return 'happy';
}
@HttpPut
global static string doPut() {
RestRequest req = RestContext.request;
System.debug('req is---------------------- ' +req);
return 'Put';
}
@HttpGet
global static string doGet() {
RestRequest req = RestContext.request;
System.debug('req is---------------------- ' +req);
return 'Get';
}
}
If that is the case, there is an option to uncheck "Require Secure Connection (HTTPS)" at the "site" settings right, what does that option do? Also, i went through the Salesforce documentation (Winter 16), and there is no where it was mentioned about this point. Is this a bug in Salesforce?
We are talking here about exposing an Apex REST web service through force.com Sites.
- Sites works on HTTP as much as on HTTPS.
- Rajagopal mentions is that among the use cases: GET, POST, PUT on HTTP or on HTTPS, there is an issue only with POST on HTTP, which get routed to the GET handler.
Sounds like a bug to me...