0

I am using as reference this documentation: https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_resources_favorites.htm

And it says that by doing an HTTP GET request to this url "/ui-api/favorites" it should retrieve "all of a user’s favorites.". But it seems it doesn't work.

I tried the following code in Execute Anonymous and received the error "HttpResponse[Status=Moved Temporarily, StatusCode=302]"

This is the code I tried in the sandbox, by the way I included some favorites to my user so it should retrieve something.

HttpRequest req = new HttpRequest();
req.setHeader('Content-Type','application/json');
string host = '{YOUR_SFDC_INSTANCE}.lightning.force.com';

String endpoint = 'https://' + host + '/ui-api/favorites';
req.setMethod('GET');
req.setEndpoint(endpoint);

Http http = new Http();
HTTPResponse res = http.send(req);

system.debug(res);

Does anyone know if the Favorite API is still in use? Thanks!

1

You have to go to Classic and copy the host Url.

Also the endpoint is not String endpoint = 'https://' + host + '/ui-api/favorites';

But

String endpoint = host +'/services/data/v45.0/ui-api/favorites';

where host is the base url in classic : eg: myPranyorg.salesforce.com

4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.