【发布时间】:2018-09-10 05:21:34
【问题描述】:
如何在 Angular 2 打字稿中发送以下内容?
要发送多个 URI,我们必须用换行符分隔它们:
curl -i -X PUT -H "Content-Type:text/uri-list" --data-binary @uris.txt http://localhost:8080/authors/1/books
uris.txt 文件包含书籍的 URI,每个都在单独的行中:
http://localhost:8080/books/1 http://localhost:8080/books/2
我知道如何发送 PUT htt 请求,但没有找到在 PUT 请求中发送多个元素的解决方案!
我无法生成这样的内容: http://localhost:8080/books/1 http://localhost:8080/books/2
Typescript 总是将 "" 放在字符串中,我在服务器端遇到错误。
我可以这样发送:
return this.http
.put(`${this.apiUrl + this.quizesUrl}/${quiz.id}${this.questionsUrl}`
, `${this.apiUrl + this.questionsUrl}/4`, QuizesService.OPTIONS_URI_LIST) // ...using put request
.map(this.handleSingleResponse) // ...and calling .json() on the response to return data
.catch(this.handleError) // ...errors if any
.finally(() => {
console.log('After updateQuestion request...');
})
;
如何从一个集合中发送多个?
【问题讨论】:
-
您是否尝试使用单个
PUT请求更新多个实体? -
是的,测验有多个问题,我想在一个请求中分配所有问题。内容类型:uri/list 有这个能力。 baeldung.com/spring-data-rest-relationships