1
在flask-restless
中執行PATCH
請求的正確方法是什麼?我得到以下響應錯誤:如何在瓶子裏不安?
{u'errors': [{u'status': 400, u'code': None, u'links': None, u'title': None, u'detail': u'Must specify correct data type', u'source': None, u'meta': None, u'id': None}], u'meta': {}, u'jsonapi': {u'version': u'1.0'}}
這裏是我的類:
class Stat(postgres.Model):
__tablename__ = 'stats'
def __init__(self,
res,
met,
cou
):
self.res = res
self.met = met
self.cou = cou
id = postgres.Column(postgres.Integer , primary_key=True , autoincrement=True)
res = postgres.Column(postgres.Enum('h' , 'd' m name='stat_res_enum') , nullable=False , unique=False)
met = postgres.Column(postgres.Enum('u_s' , 'o_t' , name='stat_met_enum') , nullable=False , unique=False)
cou = postgres.Column(postgres.BigInteger , nullable=False , unique=False)
這裏是我的要求:
data = {
"data":{
"attributes":{
"cou":3
}
}
}
response = requests.patch(url="http://127.0.0.1/api/stats/1",data=json.dumps(data),headers={'Accept' : 'application/vnd.api+json' , 'Content-Type' : 'application/vnd.api+json'})
response.json()