使用postman插件进行api测试的时候 [ 2.0 版本 ]
可以get到用户,但是使用post方式创建用户的时候老是抛出错误,是不是需要api调用需要认证啊,麻烦看看
api.test.com/users?username=wmsd&email=dfsf@qq.com&password=1234567
出现的错误信息是
{"name":"Integrity constraint violation","message":"SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 'username'\nThe SQL being executed was: INSERT INTO `user` (`status`, `created_at`, `updated_at`) VALUES (10, 1448523987, 1448523987)","code":23000,"type":"yii\\db\\IntegrityException","file":"/Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/db/Schema.php","line":628,"stack-trace":["#0 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/db/Command.php(791): yii\\db\\Schema->convertException(Object(PDOException), 'INSERT INTO `us...')","#1 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/db/Schema.php(448): yii\\db\\Command->execute()","#2 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/db/ActiveRecord.php(454): yii\\db\\Schema->insert('{{%user}}', Array)","#3 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/db/ActiveRecord.php(424): yii\\db\\ActiveRecord->insertInternal(NULL)","#4 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/db/BaseActiveRecord.php(593): yii\\db\\ActiveRecord->insert(true, NULL)","#5
共 1 个回答
cgp
注册时间:2015-10-27
最后登录:2015-12-15
在线时长:5小时32分
最后登录:2015-12-15
在线时长:5小时32分
- 粉丝1
- 金钱140
- 威望0
- 积分190