Home Rest - can payload contain data from resource uri?
Reply: 0

Rest - can payload contain data from resource uri?

mawek Published in 2017-12-07 16:55:11Z

Imagine having REST endpoint /users/{userId}/notifications/{notificationId}. When performing post on /users/{userId}/notifications resource, is it OK if notification payload contains also userId attribute?

{ "id":"123", "type":"sms", "userId":"123", "content":"something" }

It is a bit redundant since it is also part of the URI, so server can parse it, and if it was there - backend would have to decide whether it would ignore it on post, or whether it would validate equality with uri part. On the other hand, it is very handy if notification payload encapsulates all data - also userId. It could behave the same way as id - it is part of the payload but it is ignored on get request.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.309313 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO