I am using site.com to host a mini site which works fine. I need another delivery method other than manually uploading my .zip file to my site as an asset.
I have found a way to expose an endpoint referencing this fairly old document: https://developer.salesforce.com/blogs/developer-relations/2012/02/quick-tip-public-restful-web-services-on-force-com-sites.html.
I successfully created a small program to retrieve and send back information when hitting the endpoint from the CLI:
@RestResource(urlMapping='/myservice')
global class MyService {
@HttpGet
global static String doGet() {
// the site name provided
String name = RestContext.request.params.get('name');
// get the site information
Site site = [SELECT Name FROM Site WHERE Name =: name Limit 1];
String label = [SELECT MasterLabel FROM Site where Name =: site.Name].MasterLabel;
Id admin = [SELECT AdminId FROM Site where name =: site.Name].AdminId;
// get the site admin information
User contact = [SELECT id FROM User where id =: admin Limit 1];
String contactFirstName = [SELECT FirstName FROM User where id =: contact.Id].FirstName;
String contactLastName = [SELECT LastName FROM User where id =: contact.Id].LastName;
return 'The contact for the '+label+' site is '+contactFirstName+' '+contactLastName;
}
}
Is it possible to extend this type of service to accept uploading a document?
@HttpPost
method.... – John Thompson May 12 '17 at 2:21