@RestResource(urlMapping='/OFSCustomSetting/*') global class OFSCustomSettingRest { /** * カスタム設定取得 */ @HttpGet global static void doGet() { RestResponse res = RestContext.response; res.addHeader('Content-Type', 'application/json'); String jsonResponse; List ofsList = OFSSetting__c.getall().values(); if (ofsList == null || ofsList.isEmpty()) { res.statusCode = 200; jsonResponse = '{"'+ System.Label.OFSErrorStatus +'": "'+ System.Label.OFSErrorFailure +'", "'+ System.Label.OFSErrorMessage +'": "No found OFSSetting__c"}'; res.responseBody = blob.valueOf(jsonResponse); return; } else { try { res.statusCode = 200; for (OFSSetting__c ofs : ofsList) { if (String.isBlank(ofs.sqlWhere__c) == false) { ofs.reportId__c += ' ' + ofs.sqlWhere__c; ofs.sqlWhere__c = null; } } jsonResponse = Json.serialize(ofsList); // TODO ここだけです。OFSErrorStatus などや設定しない、直接データとして戻す res.responseBody = blob.valueOf(jsonResponse); return; } catch ( Exception ex ) { res.statusCode = 200; Map forJson = new Map(); forJson.put(System.Label.OFSErrorStatus, System.Label.OFSErrorFailure); forJson.put(System.Label.OFSErrorMessage, '' + ex); jsonResponse = Json.serialize(forJson); res.responseBody = blob.valueOf(jsonResponse); return; } } } }