New answers tagged

0

I recommend adding the below check RestRequest request = RestContext.request; Map requestHeaders = request.headers; if (requestHeaders.containsKey('Sfdc-Stack-Depth') && '1'.equals(requestHeaders.get('Sfdc-Stack-Depth'))){ System.debug('Do not calllout as it will cause a callout loop error'); } As described here, The SFDC_STACK_DEPTH header is ...


0

Here is the coding what i used to solve that, I used contentversion object in salesforce. Attachment attach = [SELECT Id, Name, Body, ContentType, ParentId From Attachment LIMIT 1]; ContentVersion cv = new ContentVersion(); cv.Title = 'Test Document'; cv.PathOnClient = 'TestDocument.pdf'; cv.VersionData = attach.body; //cv.IsMajorVersion = true; ...


3

Edited I did some tests with your code and setup in a Developer Org, Test 1: Log in as the user who created the Auth. Provider in Workbench Result: I can get the token in workbench. Test 2: Grant apex class access to a site and visit the site Result: I got a null as a site user. Test 3: Log in as another System Admin in Workbench Result: I got a null I ...


1

Neither Basic Auth nor client credentials grant type is supported by Salesforce for authorizing access to REST APIs (docs). In lieu of client credentials, Salesforce supports and recommends JWT Bearer flow. Both client credentials and JWT Bearer flows can be used to achieve the same goal of supporting no-user-present, machine-to-machine or application-to-...


1

Neither mode is supported. Basic Authentication is not supported at all, as it is essentially insecure, and while there are a number of OAuth modes supported, the only one that allows a password is the Password flow (grant_type=password), but this mode does not include Refresh Tokens, so your client will need to continually log in using the username and ...


0

It appears all I needed to do was add this to the test class at the start of the method (before the Account acct... line): RestRequest req = new RestRequest(); RestResponse res = new RestResponse(); req.requestURI = '/services/apexrest/xyz'; //Request URL req.httpMethod = 'POST'; RestContext.request = req; RestContext.response= res;


Top 50 recent answers are included