I seem to get an error when trying to get a list using an endpoint in GAE. The error is as follows:
04-08 01:01:30.145: I/System.out(14650): com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request 04-08 01:01:30.145: I/System.out(14650): { 04-08 01:01:30.145: I/System.out(14650): "code": 400, 04-08 01:01:30.145: I/System.out(14650): "errors": [ 04-08 01:01:30.145: I/System.out(14650): { 04-08 01:01:30.145: I/System.out(14650): "domain": "global", 04-08 01:01:30.145: I/System.out(14650): "message": "java.lang.IllegalArgumentException: id cannot be zero", 04-08 01:01:30.145: I/System.out(14650): "reason": "badRequest" 04-08 01:01:30.145: I/System.out(14650): } 04-08 01:01:30.145: I/System.out(14650): ], 04-08 01:01:30.145: I/System.out(14650): "message": "java.lang.IllegalArgumentException: id cannot be zero" 04-08 01:01:30.145: I/System.out(14650): }
This is the method I'm trying to use at my endpoint:
@SuppressWarnings({ "cast", "unchecked"}) public List<Comercio> listComercio() { EntityManager mgr = getEntityManager(); List<Comercio> result= new ArrayList<Comercio>(); try { Query query = mgr.createQuery("select c from Comercio c", Comercio.class); for (Object obj : (List<Object>) query.getResultList()) { result.add((Comercio) obj); } } finally { mgr.close(); } return result; } }
This is the entity class:
@Entity public class Comercio{ @Id private Long id; private String title; private String url; private String NEWSTYPE; public Comercio() { } public Long getId() { return id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public void setNewstypeid(String newstypeid) { this.NEWSTYPE = newstypeid; } public String getNewstypeid() { return NEWSTYPE; } }
This is AsyncTask from my Android project:
public class AsyncDatastoreArticles extends CloudAsyncTask { AsyncDatastoreArticles(Home activity) { super(activity); } @Override protected void doInBackground() throws IOException {
I need help.
Thanks in advance.
source share