1

我正在使用带有 Angular 客户端的 Symfony API。我目前正在尝试发布到我的 API,以在我的数据库中添加数据。我想创建一个通知,所以我做了一个 NotificationService:

createNotif(user: User, job: QuotationJob,  type: string): Observable<Notification> {
return this.rg.all('notifications').customPOST({
  type: type,
  user: user['@id'],
  job: job['@id'],
  readed: "false",
});

}

然后我尝试通过这样做在我的 component.ts 中使用此方法:

this.notificationService.createNotif(favoriteUser, job, notificationType).subscribe(value => {
          console.log(value);
      });

现在我只是想让 POST 工作。但我得到这个错误:

        {
      "data": {

"data": {
  "@context": "/api/contexts/Error",
  "@type": "hydra:Error",
  "hydra:title": "An error occurred",
  "hydra:description": "The property path constructor needs a string or an instance of \"Symfony\\Component\\PropertyAccess\\PropertyPath\". Got: \"integer\"",

我不明白有什么问题。用户[@id] 和工作[@id] 是这样的:/api/users/2

4

0 回答 0