On workbench I am getting:
message: Unexpected parameter encountered during deserialization: response at [line:2, column:18] errorCode: JSON_PARSER_ERROR
I validated the JSON so I don't know where the problem is. Any help is appreciated.
Apex Class
@RestResource(urlMapping='/JSON2APEX/*')
global without sharing class JSON2Apex {
public class Status {
public String type;
public String message;
public Integer code;
public String code_message;
}
public class Requests {
public Request request;
}
public Response response;
public class Response {
public Integer count;
public Double benchmark;
public List<Requests> requests;
public Status status;
}
public class Request {
public Integer id;
public String image_thumbnail;
public String title;
public String description;
public String status;
public String address;
public String location;
public String zipcode;
public String user;
public Integer date_created;
public Integer count_comments;
public Integer count_followers;
public Integer count_supporters;
public Double lat;
public Double lon;
public Integer user_follows;
public Integer user_comments;
public Integer user_request;
public String rank;
}
@httppost
global static JSON2Apex parse(String json) {
return (JSON2Apex) System.JSON.deserialize(json, JSON2Apex.class);
}
}
Payload:
{
"response": {
"count": 1,
"benchmark": 0.22567009925842,
"requests": [
{
"request": {
"id": 537481,
"image_thumbnail": "",
"title": "Request for new bin(s) - residential",
"description": "Propmain ref 3234-1114",
"status": "submitted",
"address": "36 Pine Tree Close",
"location": "Peterborough, England",
"zipcode": "PE1 1EJ",
"user": "",
"date_created": 1417173208,
"count_comments": 0,
"count_followers": 0,
"count_supporters": 0,
"lat": 52.599967,
"lon": -0.233482,
"user_follows": 0,
"user_comments": 0,
"user_request": 1,
"rank": "0"
}
}
],
"status": {
"type": "success",
"message": "Success",
"code": 200,
"code_message": "Ok"
}
}
}