public class RequestWrapper { public static GetUrlRequest GetUrlRequest; public class abc { public String ab; public String cd; public abc(String td, String cR){ this.ab = tId; this.cd = cR; } } public class GetUrlRequest { public String cd; public String sb; public String pp; public abc aO; public cbl cO; public GetUrlRequest(String cId, String sBC, String pur, abc abcInstance, cbl cblInstance){ cd = cId; sb = sBC; pp = pur; abc = abcInstance; cbl = cblInstance; } } public class cbl { public String ru; public String cu; public cbl(String rUrl, String cUrl){ this.ru = rUrl; this.cu = cUrl; } } public static RequestWrapper parse(String json) { return (RequestWrapper) System.JSON.deserialize(json, RequestWrapper.class); } }
I formed this class for the json body that I need to pass in my http post request. I created this class from json generator and added the constructors. can someone please tell me how do I initialize this class, I will be setting dynamic values to this later, but right now I want to hardcode values to this class vars and send it as the request body.
I tried to as follows but this gives me error:
RequestWrapper.cbl('stringcblValue', 'stringcuvalue'); RequestWrapper.abc('somestringvalue', 'somestringvalue'); String jsonRequestBody = JSON.serialize(RequestWrapper.GetUrlRequest); req.setBody(jsonRequestBody);
Error is: Method does not exist or incorrect signature: void cbl(String, String) from the type RequestWrapper