2

I am trying to call ui api from apex code with in a lightning component.

String instance = System.URL.getSalesforceBaseURL().toExternalForm();
    String restApi = instance + '/services/data/v42.0/ui-api/object-info/Account';

    HttpRequest req = new HttpRequest();
    req.setEndpoint(restApi);
    req.setMethod(method);
    if(String.isNotBlank(requestBody)){
        req.setBody(requestBody);
    }
    //session id is valid 
    req.setHeader('Authorization', 'Bearer '+this.sessionId);

    String body = '';
    try{
        Http h = new Http();
        HttpResponse res = h.send(req);
        body = res.getBody();
        if(res.getStatusCode() == 200){
            //Parse JSON response
            return body;
        } else {
            System.debug(res.getStatusCode());
            System.debug('Error body ' + body);
        }
    }catch(System.CalloutException ex){
        //handle callout error
    }
    return body;

This piece of code returns correct result when the component displayed by internal user. However, when component is display on Community and viewed by Community Portal User, I have following error:

 [{"message":"The requested API is not available to portal users. You may need to specify a community for portal user access.","errorCode":"FUNCTIONALITY_NOT_ENABLED"}]

I tried to make rest api(like:"/services/data/v42.0/sobject/Account/describe") calls using portal user, calls return successfully.

Does that mean salesforce ui api does not support calls made by portal user? or there is some settings I need to turn on for portal user? Anyone can point me to any Salesforce documentation?

1 Answer 1

0

On Summer '18 release it seems like salesforce fix this issue: Please check the release note page 493.

https://resources.docs.salesforce.com/214/latest/en-us/sfdc/pdf/salesforce_summer18_release_notes.pdf

I need to test this out.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .