You need to sign in to do that
Don't have an account?
Travis Hendrix
Query Validation Rules
I am trying to query validation rules in apex. I was trying to do it with a callout but keep getting an error: No operation available for request. Here is the code I am using.
HTTP h = new HTTP(); HTTPRequest req = new HTTPRequest(); req.setMethod('GET'); req.setHeader('Content-Type', 'text/xml'); req.setHeader('SOAPAction', 'ValidationRule'); String b = ''; b += '<?xml version="1.0" ?>'; b += '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:metadata.tooling.soap.sforce.com">'; b += '<soapenv:Header>'; b += '<urn:SessionHeader>'; b += '<urn:sessionId>'+UserInfo.getSessionId()+'</urn:sessionId>'; b += '</urn:SessionHeader>'; b += '</soapenv:Header>'; b += '<soapenv:Body>'; b += '<urn:ValidationRule>'; b += '</urn:ValidationRule>'; b += '</soapenv:Body>'; b += '</soapenv:Envelope>'; req.setBody(b); req.setCompressed(false); req.setEndpoint('https://na34.salesforce.com/services/Soap/T/35.0'); HTTPResponse resp = h.send(req); System.debug(resp.getBody());
Andrew Fawcett from FinancialForce built an Apex wrapper around the Tooling API that utilizes SOAP; should be perfect for this use case:
https://github.com/afawcett/apex-toolingapi