Hot answers tagged

5

Do not write your own JSON. This is always problematic. Instead, serialize an object: String payload = JSON.serialize( new Map<String, Object> { 'jsonrpc' => '2.0', 'method' => 'host.get', 'params' => new Map<String, Object> { 'output' => new String[] { 'host' }, ...


4

As the documentation states, setBody accepts a String argument. In this case, you need to serialize the model. JSON2Apex payload = new JSON2Apex(...); request.setBody(JSON.serialize(payload)); I'd recommend you also rename JSON2Apex to something more specific to what you are working on.


3

Might be easier to create a map and serialize it. Map<String,Object> jsonMap = new Map<String,Object>{ 'jsonrpc' => '2.0', 'params' => new Map<String,Object>{ 'output' => new String[]{'host'}, 'groupids' => new Integer[]{1235} }, 'auth' => yourAuthString }, Then just serialize it for the string: String ...


2

All you have to do is collect your filter values outside the loop. Set<Id> relatedServiceIds = new Set<Id>(); for (csord__Service__c service : servicesList) relatedServiceIds.add(service.el_Related_Service__c); Map<Id, csord__Service__c> relatedServices = new Map<Id, csord__Service__c>([ SELECT ... FROM ... WHERE Id IN :...


2

Change you start to this and it should work as it has to add values in array before passing that to execute method. So here if test is running we clear the array and add 1 so that the execute gets called at least once. global Iterable<Integer> start(Database.BatchableContext context) { Integer[] values = new Integer[0]; while(values.size() < ...


Only top voted, non community-wiki answers of a minimum length are eligible