July 2017
Intermediate to advanced
374 pages
8h
English
This API function is used to update the attributes of the users in the MongoDB users collection.
In order to update the documents in the MongoDB user collection for a specific user, we will need to rewrite the upd_user(user) method as follows:
def upd_user(user):
api_list=[]
print (user)
db_user = connection.cloud_native.users
users = db_user.find_one({"id":user['id']})
for i in users:
api_list.append(str(i))
if api_list == []:
abort(409)
else:
db_user.update({'id':user['id']},{'$set': user}, upsert=False )
return "Success"
Now that we have updated the method, let's test it on POSTMAN and check the response.
The following screenshot shows the response of the update API request using POSTMAN:
Let's validate the ...