RESTful Many-to-Many possible?

前端 未结 3 1987
天命终不由人
天命终不由人 2020-12-28 09:19

How to I represent a complex resource for a REST post?

Hello, Currently I have an application which when the user hits \"save\" it iterates over all of the form el

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-28 09:54

    I think you're really asking, "How do I represent complex data in a form suitable for transmission within a POST?", right? It's less to do with REST and more to do with your choice of media type. I would suggest starting with a pure JSON representation, using arrays and cross-referenced ID fields to map the relationships. You could also do this with XML, of course.

    The examples you gave look right on the money. You just need to ensure that both parties (browser and server) agree on the structure and interpretation of the media type you use.

提交回复
热议问题