You need to sign in to do that
Don't have an account?

Best way to generate JSON for requestBody
I am testing my POST REST API service in apex.
RestRequest request = new RestRequest(); request.requestURI = MY_API_ENDPOINT; request.httpMethod = 'POST'; request.addHeader('Content-Type', 'application/json'); String jsonBody = '<some_json_here>'; request.requestBody = Blob.valueOf(jsonBody); RestContext.request = request; /* * assertions here */The json string I will be using is lengthy. I can simply form a string inline in the code by use '+' operator repetatively. But what is the best way of doing this?
OurCustomMetadata__mdt[] rows = [SELECT Field1__c FROM OurCustomMetadata__mdt WHERE Field2__c = 'fieldValue'];
All Answers
OurCustomMetadata__mdt[] rows = [SELECT Field1__c FROM OurCustomMetadata__mdt WHERE Field2__c = 'fieldValue'];
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_testing_static.htm
https://salesforce.stackexchange.com/questions/54527/test-loaddata-undocumented-but-useful-behavior-loading-relationships