1

If I offer a POST in my REST API, say like

https://api.myservice.com/myresource

and I want to accept a complex JSON string/object from within the POST.

Should I

  • omit the JSON and map the entire object to the URL (which would be quite uncool)

  • add the JSON Data as key => value pairs to the JSON

  • am I able to just access the raw body data or wouldn't that be any more restful?

shredding
  • 4,376
  • 3
  • 36
  • 66

2 Answers2

1

Regardless of the options you have listed I don't see any impact on any of the REST constraints. It is more valuable to ask yourself am I violating any of the REST constraints and if so, what benefits am I losing and make your decision on the relative pros and cons.

Achieving "RESTful" status should not be the end goal. Picking the constraints that are important to your application and applying them should be the goal.

Darrel Miller
  • 129,370
  • 30
  • 183
  • 235
1

When you do POST to the URL https://api.myservice.com/myresource you would be creating a myresource with the details in the POST body. The URL generally should contain your resources.

basiljames
  • 4,400
  • 3
  • 22
  • 40