I am trying to integrate salesforce and google books via rest api..But it is throwing the below error -
System.JSONException: Malformed JSON: Expected '[' at the beginning of List/Set
public class GoogleBooks {
public class Items {
public String kind {get;set;}
public String id {get;set;}
public String etag {get;set;}
public String selfLink {get;set;}
}
}
public class GoogleBooksResponse{
String kind;
Integer totalItems;
List<GoogleBooks> items; //Your existing class.
}
And in the anonymous window i am running the below -
String s;
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setHeader('Content-Type','application/json');
req.setHeader('Accept','application/json');
req.setEndpoint('https://www.googleapis.com/books/v1/volumes?q=harry+potter');
Http http = new Http();
HTTPResponse res = null;
res = http.send(req);
s = res.getBody();
List<GoogleBooksResponse> result = (List<GoogleBooksResponse>)JSON.deserialize(s , LIST<GoogleBooksResponse>.class);
I tried running the endpoint in ARC tool which gave me a big JSON response. When i validated the JSON, it showed some error.
**https://www.googleapis.com/books/v1/volumes?q=harry+potter**
Has anyone faced this issue.