Mishirin
Mishirin

Reputation: 125

Restangular customPost: The property path constructor needs a string or an instance of PropertyPath, got integer

I'm using a Symfony API with an Angular client. I'm currently trying to post to my API, to add a data in my database. I want to create a notification, so I did a 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",
});

}

I then try to use this method in my component.ts by doing this:

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

For now I'm just trying to make the POST work. But I get this error:

        {
      "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\"",

I don't understand what is the problem. User[@id] and job[@id] are like this : /api/users/2.

Upvotes: 2

Views: 124

Answers (0)

Related Questions