简体   繁体   中英

Storing arrays of text into Parse database

I am creating a mail system where user A sends a piece of text to user B, user B stores the text in an array in a column called Inbox (which has the attribute array).

I create 5 users, the first 2 users responds with "POST https://api.parse.com/1/classes/_User/fjT08jUUk8 400 (Bad Request)"

HOWEVER, the last 3 users works perfectly fine. I'm really frustrated because I just can't figure out what the problem is. All the users are created with the same conditions.

I'll link the code used here:

<textarea name="msg" id="msg" rows="10" cols="60"></textarea>
<button ng-click="sendMessage(fetched_user.id)">Send</button>

(fetched_user.id is the corresponding id for the user you're targeting, double checked it)

$scope.sendMessage = function(UID) {     
    var query = new Parse.Query(Parse.User);

    query.equalTo('objectId', UID);
    query.first({
        success: function(object) {
            var text = $('#msg').val();
            object.add("Inbox", text );
            object.save();
            $scope.$apply();    
        },
        error: function(error) {
        alert("Error: " + error.code + " " + error.message);
        }

    });
}

As always I'm really greatful for any kind of answer!! Thanks in advance :)

SOLVED!!!!

After a lot of research I found that object.save() was the problem and that it was giving me this error: Error: 206 Parse::UserCannotBeAlteredWithoutSessionError

I believe that this is some kind of security measure, that not everyone can alter users as they like. This has to be done from cloud code, which per say is a whole other department. So for you guys who want to get this done, get your reading into Parse Cloud Code!

您可以使用request.user获取任何云函数的调用用户, request.user是指向用户的指针,应使用该指针而不是传递objectId。

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