I want to create a visualforce page by using Tooling api and I am doing this like below :
@RemoteAction
public static String createInlinePage(String objectName) {
objectName = String.escapeSingleQuotes(objectName.trim());
System.debug(objectName+'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~objectName');
String salesforceHost = GetBaseUrlForInstance;
System.debug(GetBaseUrlForInstance);
String urlmy = salesforceHost+'/services/data/v29.0/sobjects/ApexPage';
HttpRequest req = new HttpRequest();
req.setMethod('POST');
req.setEndpoint(urlmy);
req.setHeader('Content-type', 'application/json');
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId());
req.setBody('{"Name" : "'+objectName+'InlineAttachmentPage","Markup" : "<apex:page standardController=\''+objectName+'\' standardstylesheets=\'false\' cache=\'false\'><c:AttachPathInlineComponent objectId=\'{!$CurrentPage.parameters.id}\'/></apex:page>","ControllerType" : "1","MasterLabel":"'+objectName+'InlineAttachmentPage","ApiVersion":"29.0"}');
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());
return res.getBody();
}
This code is working fine for standard Object but not working for custom Object.
When I tried this for custom Object I got this error
{"message":"The name can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores.: Name","errorCode":"FIELD_INTEGRITY_EXCEPTION","fields":["Name"]}
Please guide me where I am wrong .