14371

How do I update a list data_relation in Python Eve

Question:

I have a model 'users' and a schema for it, which includes a one-to-many relation back to users:

'followers': { 'type': 'list', 'schema': { 'type': 'objectid', 'data_relation': { 'resource': 'users' } } },

I am trying to update the list of followers. I tried sending PATCH request to the <strong>/users/545c7dccb505970bbf0e5ad1</strong> endpoint with a 'followers' key and a list of objectids but it doesn't work. Also tried sending a PUT request to <strong>/users/545c7dccb505970bbf0e5ad1/followers/</strong> but no luck.

So how do I add an object to this list with Python Eve REST API?

GET /users/545c7dccb505970bbf0e5ad1/ { "_updated": "Fri, 07 Nov 2014 08:07:40 GMT", "public_key": "test", "_etag": "256d6da738a0f39929d40d1c868e1f67661460be", "_links": { "self": { "href": "/users/545c7dccb505970bbf0e5ad1", "title": "User" }, "parent": { "href": "", "title": "home" }, "collection": { "href": "/users", "title": "users" } }, "active": false, "_created": "Fri, 07 Nov 2014 08:07:40 GMT", "_id": "545c7dccb505970bbf0e5ad1" } PATCH /users/545c7dccb505970bbf0e5ad1 { "_status": "ERR", "_error": { "message": "You don't have the permission to access the requested resource. It is either read-protected or not readable by the server.", "code": 403 } } PUT /users/545c7dccb505970bbf0e5ad1/followers { "_status": "ERR", "_error": { "message": "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.", "code": 404 } }

Answer1:

doesn't work is awfully broad... however at a guess you need to send your _etag token the server returned when fetching or creating the user... this is required to prevent updating from an out of date model

Recommend

  • LEFT JOIN doesn't behave as expected as gives NULLs in MySQL
  • How to change eve's IP address?
  • How to protect custom endpoints using BasicAuth?
  • authentication token issue EVE
  • c++ create an array with string::size
  • How can I see Python's __builtins__ source code?
  • Where can I get runkit DLL extensions for PHP 5.3+?
  • how to get the drawing graphic on picture box in c#
  • How to read data from a text file if the file location is not known in c#?
  • View/Download Pdf Files in React - Router 4
  • import scipy.sparse failed
  • During installation of Django, why do I keep getting ImportError: No module named django?
  • where do I find the xml.dom python package for the python-2.6.0-8.9.28 and I have a suse/x86_64 vers
  • Python pickle not one-to-one: different pickles give same object
  • Authentication in Play! and RestEasy
  • jQuery ready not fired after rails link_to is clicked
  • Display images in Django
  • How to attach a node.js readable stream to a Sendgrid email?
  • Word Open XML Mail Merge
  • Bad request using file_get_contents for PUT request in PHP
  • Java: can you cast Class into a specific interface?
  • AES padding and writing the ciphertext to a disk file
  • Updating server-side rendering client-side
  • How to extract text from Word files using C#?
  • Hazelcast - OperationTimeoutException
  • R: gsub and capture
  • RestKit - RKRequestDelegate does not exist
  • AT Commands to Send SMS not working in Windows 8.1
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Comma separated Values
  • Matrix multiplication with MKL
  • Revoking OAuth Access Token Results in 404 Not Found
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Angular 2 constructor injection vs direct access
  • How do I configure my settings file to work with unit tests?
  • Java static initializers and reflection
  • Android Google Maps API OnLocationChanged only called once
  • Is it possible to post an object from jquery to bottle.py?
  • UserPrincipal.Current returns apppool on IIS
  • How to load view controller without button in storyboard?