I have a gae project that uses cloud end points in Java which is a very simple CRUD application.
I have some PUT requests that change the datastore entities and GET requests that retrieve them. I find the GET requests always do not return the latest value of the entities. This is happening for several GET requests. When I check the saved value in my datastore viewer I can confirm the new value is saved correctly.
I tried this with Google API explorer and also with another REST client (called Postman available in chrome web store).
The pattern seems to be this -
1) send PUT request to change entity
2) send GET request to retrieve entity. sometimes I see old value and sometime I see new value. I can confirm latest data is saved from datastore viewer. This happens for multiple GET requests.
This seems like pretty basic functionality and may be I am doing something wrong. This is how my api annotations look like -
@Api (name = "content",
scopes = { "https://www.googleapis.com/auth/userinfo.email" }
)
public class ContentAPI extends APIBase {
@ApiMethod(path="setcontent", httpMethod = HttpMethod.PUT)
public APIResponse setContent(@Named("content_html") String html,
@Named("tag") String tag, @Named("publish") boolean publish, User user) {
...
//save content in the datastore
}
@ApiMethod(path="getcontent", httpMethod = HttpMethod.GET)
public APIResponse getContent(@Named("tag") String tag,
User user) {
...
//retrieve the saved content and send it back.
}
Has anyone encountered such issues before ? Any help would be appreciated.
[Edit] - this looks like a datastore issue and not a cloud endpoint issue. I have opened another question [here] ( Unable to get saved entity using objectify )
Regards,
Sathya
It turns out this is not an issue with cloud end point.
I am using objectify as my data access API and I had forgotten to add objectify filter in web.xml as mentioned in Objectify wiki page
I added the following in my web.xml and the problem was solved.
<filter>
<filter-name>ObjectifyFilter</filter-name>
<filter-class>com.googlecode.objectify.ObjectifyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ObjectifyFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.