2013-04-17 2 views
3

나는 그것이 공식 처마의 문서에서 설명하고 service_name.post (스키마 = SomeSchemaClass) 같은 장식을 통해 그렇게 할로 스키마 유효성 검사를 추가하려고하지만쿠 리에 커튼이 작동하지 않습니다 제대로

import colander 


class TrackSchema(colander.MappingSchema): 
    genre = colander.SchemaNode(colander.String(), location="body", type='str') 

@track.post(schema=TrackSchema) 
def create_track(request): 
    ... 
작동하지 않는 것

와 나는

"status": "error", "errors": [{"location": "body", "name": null, "description":  "Expecting value: line 1 column 2 (char 1)"}, {"location": "body", "name": "genre", "description": "genre is missing"}]} 

내가 쿼리 문자열 및 헤더와 같은 위치 인수의 다른 유형을 시도하지만이 같은 오류가 발생했습니다 오류 얻을.

답변

3

은 동일한가 발생하고 cornice.util.extract_request_data 기능을 보면 파고 후, 당신은 그것의 json.loads(request.body)은 그래서 당신은 JSON으로 데이터를 게시 할 필요가 JSON으로 몸을로드하는 것을 볼 수 있습니다 :

curl -H "Content-Type: application/json" -X POST http://localhost:6543/foo -d '{"foo": "bar"}' 

HTH