【发布时间】:2015-10-12 21:46:27
【问题描述】:
我正在使用 Angular 的 $http 服务来发出 web api 请求。当我使用 GET 方法时,两个参数值被添加到查询字符串中:
// http://foo.com/api/test?heroId=123&power=Death+ray
$http.get("/api/test", {
params: { heroId: 123, power : "Death ray" }
})
但是,当我使用 PUT 方法时,参数被 JSON 编码并作为请求负载发送:
// {"params":{"heroId":123,"power":"Death ray"}}
$http.put("/api/test", {
params: { heroId: 123, power : "Death ray" }
})
使用 PUT 时如何强制将参数添加到查询字符串中?
【问题讨论】: