简体   繁体   中英

Cannot insert object in Parse.com with parse4j API in JAVA

I am using Parse.com for communicating with iOS application and Web Browser. I have registered in parse.com and created an application. Now I have an iOS application ready to insert an object in that application which is working fine. Now comes the backend part, I am using JAVA for web application. Now,

https://parse.com/docs/api_libraries

According to this link, I can see the API/ Libraries I can use in JAVA is

Almonds mobile-parse-api Parse4j ParseFacade

Among this 4, I have selected Parse4j to build web application with.

I am using Eclipse, I have installed GWT plugin, created a web application. Now I am adding this parse4j.jar file to that project, Added it to the build path also. And then I try to write this code

try {

        Parse.initialize("my app id", "my rest app id");        

        ParseObject gameScore = new ParseObject("GameScore");
        gameScore.put("score", 1337);
        gameScore.put("playerName", "Sean Plott");
        gameScore.put("cheatMode", false);
        gameScore.save();

        return "OK";
    } catch(IllegalArgumentException e){
        e.printStackTrace();
        return "KO";
    }
    catch(ParseException e){
        e.printStackTrace();
        return "KO";
    }

It doesn't insert the object to parse cloud. Please help why isn't working? Am I missing anything to write?

As far as I see, the code is correct. However, if Parse4j does not save the entry this means that you write wrong the attribute name or class name. Just check the names and class name then reply back.

Regards.

One way to validate is the do a Query, get the object and print all the attributes / data types. Then store these as static class level constants and use them throughout your class for setting values in new objects to persist.

If the get query doesn't work (without any filters), which means your class name is incorrect.

Good Luck!

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM