function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kpnkpn 

Salesforce REST API Mock Response

I just need to provide mock responses for the all the REST API's I'm developing and I'll be sendingmock=true in the request parameter. If mock=true, then it should bypass the logic in apex code and just send the response. what is the best way to achieve this?

What I'm doing right now is, I'm just looking for the mock parameter and if true, sending the response back. So I'm storing the dummy JSON in a variable to send it back. Is there any other approach?
Best Answer chosen by kpn
SKolakanSKolakan
Check this: https://developer.salesforce.com/blogs/developer-relations/2013/03/testing-apex-callouts-using-httpcalloutmock.html