2014-11-07 5 views
0

내가 가진를 업데이트하려면 어떻게 모델 '사용자와 사용자에게 다시 일대 다 관계를 포함하고 이에 대한 스키마 :파이썬의리스트 data_relation 이브

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

내가하려고 추종자 목록을 업데이트하십시오. /users/545c7dccb505970bbf0e5ad1 엔드 포인트에 'followers'키와 objectid 목록이 있지만 작동하지 않는 Patch 요청을 보냈습니다. 또한 /사용자/545c7dccb505970bbf0e5ad1/추종자/으로 PUT 요청을 보냈지 만 운이 없었습니다.

그래서이 목록에 Python Eve REST API를 사용하여 객체를 어떻게 추가합니까?

GET /users/545c7dccb505970bbf0e5ad1/ 
{ 
    "_updated": "Fri, 07 Nov 2014 08:07:40 GMT", 
    "public_key": "test", 
    "_etag": "256d6da738a0f39929d40d1c868e1f67661460be", 
    "_links": { 
     "self": { 
      "href": "https://stackoverflow.com/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 
    } 
} 

답변

2

doesn't work 그러나 당신이 가져 오는 또는 사용자를 생성 할 때 서버가 반환하여 _etag 토큰을 보낼 필요가 추측에 ... 굉장히 광범위 ... 이것은 최신 모델

의 부족에서 업데이트 방지하기 위해 필요
+0

서버에서 _netid 토큰을 반환하는 위치는 어디입니까? 이것은 어떤 종류의 헤더입니까? 나는 JSON에서 그것을 보지 못한다. –

+0

해당 _etag 수정보기 ... –

+0

감사합니다. 요청에 "If-Match"헤더를 추가하고 거기에 _etag 값을 넣어야했습니다. –