You need to sign in to do that
Don't have an account?
sasham
Need a help on the get request apex class
our client is supposed to send us notification after the resuts has been reviewd.
1) approval notification
2)Results are availble
these are the urls they asked me to set up in our end
http://example.com/notif?id={id}&status=approved
http://example.com/notif?id={id}&status=resulted[&result_type={result}]
For that . I need to setup up an apex class as a REST endpoint for an HTTP GET request that an external system is sending notification.
Please le me know is the right way do or please guide me
1) approval notification
2)Results are availble
these are the urls they asked me to set up in our end
http://example.com/notif?id={id}&status=approved
http://example.com/notif?id={id}&status=resulted[&result_type={result}]
For that . I need to setup up an apex class as a REST endpoint for an HTTP GET request that an external system is sending notification.
Please le me know is the right way do or please guide me
@RestResource(urlMapping='/sample/approvalnotifications') global without sharing class Rest_Approval_Notification { @HttpGet global static void doGet() { System.debug(RestContext.request.requestBody); restresponse res=restcontext.response; String notification_id = RestContext.request.params.get('id'); String notification_status = RestContext.request.params.get('status'); System.debug(notification_id); System.debug(notification_status); //hadling error code and logic for processing } }
I have question on this folowwing and how do i use the paarameter for this [&result_type={result}]. parynot undestanding properly.
http://example.com/notif?id={id}&status=resulted[&result_type={result}]
We use addParameter method of RestRequest class when we want to add the parameter into the URL of the request and addPetemer is basically map which takes Key Value where Key is the parameter and value is the value that we are passing to that param.
In your case use AND
We use addHeader method of RestRequest Class when we want to add the values into the header and it also takes the parameters in the form of Key Value pair. For example, if we want to add Authorization, Content-Type then we should go for addHeader.
Hope this will help you :)
Regards,
Amit
http://example.com/notif?id={id}&status=resulted[&result_type={result}]
Is it the smae as
http://example.com/notif?id={id}&status=resulted&result_type={result}
any difference.
One mre question :
When i want to authenticate the request comming to saleforce from external system without using OAuth .
How to validate the rquest to make sure that it is coming from the source that we expect(Ex- XY company making request to our salesforce)
Isit possible to valdate using
String hostname = RestContext.request.Header('Host');. even thoung if they (xyc company) are adding the header for 'Host'