On recieving a response from the external system, I used Json2Apex to create the apex class viz., AuthCalloutPostWrapper
When I use the following debug
System.debug('##res.getBody##'+res.getBody());
I get a proper JSON response.
requestbody##{ "short_description" : "test", "caller_id" : "00001xx3", "priority" : "High", }
But when I used this...
String responseBody = res.getBody();
AuthCalloutPostWrapper JSONDetails=(AuthCalloutPostWrapper) System.JSON.deserialize(responseBody, AuthCalloutPostWrapper.class);
System.debug('##JSONDetails##'+JSONDetails);
JSONDetails return me null in all the parameters.
JSONDetails##AuthCalloutPostWrapper:[caller_id=null, priority=null, short_description=null]
UPDATE: Also using..
AuthCalloutPostWrapper myJSON = AuthCalloutPostWrapper.parse(responseBody);
returns me null in all the parameters.
UPDATE: For the code below:
HTTPResponse res = http.send(req);
System.debug('##res.getBody##'+res.getBody());
Here's the full response:
res.getBody##{"result":{"location":"","expected_start":"","reopen_count":"0","close_notes":"","impact":"1","urgency":"1","sys_domain":{"link":"xxx/table/sys/global","value":"global"},"description":"","group_list":"","priority":"1","delivery_plan":"","sys_mod_count":"0","work_notes_list":"","follow_up":"","closed_at":"","sla_due":"","delivery_task":"","sys_updated_on":"2015-12-17 01:49:04","parent":"","work_end":"","number":"xxx123","closed_by":"","work_start":"","calendar_stc":"","business_duration":"","category":"inquiry","incident_state":"1","activity_due":"","correlation_display":"","company":"","active":"true","due_date":"","assignment_group":"","caller_id":{"link":abc/api/now/table/sys_user/ababd","value":"ababd"},"knowledge":"false","made_sla":"true","comments_and_work_notes":"","parent_incident":"","state":"1","user_input":"","approval_set":"","reassignment_count":"0","rfc":"","u_record_url":"","child_incidents":"0","opened_at":"2015-12-17 07:49:04","short_description":"test as subject","order":"","sys_updated_by":"admin","resolved_by":"","notify":"1","upon_reject":"cancel","approval_history":"","problem_id":"","work_notes":"","calendar_duration":"","close_code":"","sys_id":"xxxx","approval":"not requested","caused_by":"","severity":"3","sys_created_by":"User1","resolved_at":"","assigned_to":"","bus_abc":"","sys_domain_path":"/","cmdb_ci":"","opened_by":{"link":"xxx/api/now/table/sys_user/abc","value":"abadw"},"subcategory":"","sys_class_name":"incident","watch_list":"","time_worked":"","contact_type":"phone","escalation":"0","comments":"test"}}
Let me know where I might have gone wrong. Thanks in advance!