Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Update Users table collection PUT

Hi Hawk -

Could you please show us the network tab in your browser DevTools, what is shown there?

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Update Users table collection PUT

Hi Illya,

I'm using some development tool to send the request from Oracle DB to Appery DB. I'm not using a browser. The message above is the response I got back from Appery DB.

How can I test it in the browser? I cannot create UPDATE service on Users collection in Appery.

I tried FireFox as follows:

Many thank, Image

Image

Many thanks,

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Update Users table collection PUT

Hi Hawk,

Multiple update for users not allowed.

You need to use update user REST.

precode

curl -X PUT
-H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9"
-H "X-Appery-Session-Token: c6771e2f-44ae-42ea-9946-5fa320578233"
-d "{"email":"stacy@somemail.com"}"
https://api.appery.io/rest/1/db/users/54539efee4b05c4ac3b9737f

/code/pre

See details here: http://devcenter.appery.io/documentat...

Regards.

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Update Users table collection PUT

Hi Yurii,

In my last attempt, I used the following:
precontent := '{"username":"star1234","password":"star1234"}';
url:= 'https://api.appery.io/rest/1/db/users'||A_id ; /pre

Where I concatenate A_id (which is the variable contains one user _id) to the URL. So the real value is something like this:

pre 'https://api.appery.io/rest/1/db/users54539efee4b05c4ac3b9737f'/pre

So I guess I'm updating only one user. right?

In addition, I used the content:
precontent := '{"username":"star1234","password":"star1234"}';/pre

and
precontent := '{"operations":{"$set": "username":"star1234","password":"star1234"}}';/pre

and
precontent := '{"password": { "$set": "star1234"}}';/pre

And all gave me the same error in the response!

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Update Users table collection PUT

Hi Hawk,

Your code:

pre

url:= 'https://api.appery.io/rest/1/db/users'||A_id ;

/pre

Is not correct cause of there is not "/" between "users" and "userId".

Please use this one:

pre

url:= 'https://api.appery.io/rest/1/db/users/'||A_id ;

/pre

Regards.

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Update Users table collection PUT

Many thanks Yurii !

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Update Users table collection PUT

Hi Yurii,

I'm trying to update users passwords from Oracle DB. I need to use one user here to retrieve session-Token. But the problem is, this user is only allowed to update its own password. And when I use the session-Token with other users, I receive the response : does not have write permission to this object

I understand it's because of ACL value. When I add the user I'm using to that object, I can then update the password. But I need to write permission to this user for all objects (I have 2000 users), so I cannot go to acl field for each of them and update them one by one.

Is there any easier way to grant one user (e.g. admin) write permission over all users (update their ACL)?

Thanks,

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Update Users table collection PUT

Hi Hawk,

For this case you can use Master key it will allow you access objects without session token.

Please read more about it here: http://devcenter.appery.io/documentat...

Note: master-key is very sensitive information. So it's better to use it in Server code to avoid access this information to other users.

Regards.

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Update Users table collection PUT

Thanks Yurii,
Can I use Master key to delete entire collection from Oracle without using _id's values?
In fact deleting the collection object by object is taking major time for a collection of 10,000 objects.

Thanks,

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Update Users table collection PUT

Hi Hawk,

Unfortunatly, currently there is not such api in Appery DB.

But here is a solution to improve this processing speed:

  1. Create Server script.

  2. Populate it with following JS code:

    pre

    var dbId = "52fd3d06e4b0a25c11cxxx17";
    var collectionName = "tempCollection";
    var query = [] ;

    try
    {

    var params = {};

    params.criteria =
    {
    //here you can add query paremeters.
    };

    queryResult = Collection.query(dbId, collectionName, params);

    for(var i = 0; i < queryResult&#46;length; i++){
    Collection&#46;deleteObject(dbId, collectionName, queryResult&#46;_id);
    queryResult
    };

    response&#46;success({message: (queryResult&#46;length + " items deleted")});
    }
    catch (e)
    {
    response&#46;success("message: " + e&#46;message + "ncode: " + e&#46;code);
    }

    /pre

  3. Also you specify in this screen needed search criteria to delete items.

    Regards.

Return to “Issues”