Note that there are some explanatory texts on larger screens.

plurals
  1. PO"Id cannot be zero" - GoogleJsonResponseException 400 Bad Request
    primarykey
    data
    text
    <p>I seem to be getting an error when trying to retrieve list using endpoint in GAE. The error is as follow:</p> <pre><code>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): } </code></pre> <p>This is the method I'm trying to use in my endpoint:</p> <pre><code>@SuppressWarnings({ "cast", "unchecked"}) public List&lt;Comercio&gt; listComercio() { EntityManager mgr = getEntityManager(); List&lt;Comercio&gt; result= new ArrayList&lt;Comercio&gt;(); try { Query query = mgr.createQuery("select c from Comercio c", Comercio.class); for (Object obj : (List&lt;Object&gt;) query.getResultList()) { result.add((Comercio) obj); } } finally { mgr.close(); } return result; } } </code></pre> <p>This is the entity class:</p> <pre><code>@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; } } </code></pre> <p>This is the AsyncTask from my android project:</p> <pre><code>public class AsyncDatastoreArticles extends CloudAsyncTask { AsyncDatastoreArticles(Home activity) { super(activity); } @Override protected void doInBackground() throws IOException { // TODO Auto-generated method stub List&lt;Comercio&gt; list = endpoint.listComercio().execute().getItems(); if (list != null) { //DO SOMETHING } } } </code></pre> <p>Please i need help.</p> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload