Format of data in PUT requests

早过忘川 提交于 2019-12-23 04:40:35

问题


I am preparing my server-side application to handle PUT requests comming from an emberjs client (using ember-data). The client side application is not yet ready, so that I am not able to see the real requests (this in the hands of another developer). I nevertheless want to implement the server side. Where can I find information about the detailed format of PUT requests? I need two things:

  1. What is the emberjs application going to send in the URL, headers and body of the request?
  2. What is the emberjs application expecting as reply to the the PUT request?

Here you can find a description of the REST interface which emberjs assumes, but I have been unable to find detailed information about PUT requests.


回答1:


Assuming you are using ember-data's default RESTAdapter, the following is the default format:

Let's say you are updating a post with the following attributes:

id: 50,
title: 'PUT requests'
body: 'Ember-data has a lot of potential'
isPublished: false

The PUT request will be made to the URL: '/posts/50'.

the payload submitted in the PUT request will be in the following format:

{
  "post": {
    "id": 50,
    "title": "PUT requests",
    "body": "Ember-data has a lot of potential",
    "is_published": false
  }
}

The RESTAdapter expects the response to be in the same format as above.



来源:https://stackoverflow.com/questions/15635328/format-of-data-in-put-requests

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!