2015-11-26 14:28:07 4746次浏览 1条回答 0 悬赏 10 金钱

可以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 
  • 回答于 2015-11-26 14:54 举报

    你这是post?

    4 条回复
    回复于 2015-11-26 14:58 回复

    你好,我不明白你说的什么意思?postman里面选择的是post啊

    回复于 2015-11-26 15:22 回复

    看你给的是get链接,yii中刚好有默认指定部分操作只能post。

    回复于 2015-11-26 15:23 回复

    有错误信息,就顺藤摸瓜咯

    回复于 2015-11-26 15:34 回复

    你好,请问你怎么区分的get的链接和post链接的,麻烦你了

您需要登录后才可以回答。登录 | 立即注册
cgp
助理

cgp

注册时间:2015-10-27
最后登录:2015-12-15
在线时长:5小时32分
  • 粉丝1
  • 金钱140
  • 威望0
  • 积分190

热门问题