function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
pinkipinki 

Set dynamic parameters in req.setBody in ToolingAPI

Hi, I am new to ToolingAPI. I have written code to create a VF Page from a class using Tooling API. Now what I require is to create Visualforce Pages based on the user's selection of picklist values. For example, a picklist field VFPageValues contains 'A','B','C'. Now, when user selects picklist value A, VF page created will be 'TestPageA', if user selects picklist value B, VF page created will be 'TestPageB'.

I have taken the user-selected picklist value in a string say,mcc. How can I incorporate this in the req.setBody() parameter?
Currently I have:

req.setBody('{"Name" : "TestPage","Markup" : "<apex:page>hello</apex:page>","ControllerType" : "0","MasterLabel":"TestPageFromRest","ApiVersion":"29.0"}');

within the public static void createPage() {} method which runs when user selects a picklist value. 

But this creates just page "TestPage" and does not append the user-selected picklist value. What is the proper syntax to add the mcc value to this req.setBody parameter?