我正在使用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" }
})
Run Code Online (Sandbox Code Playgroud)
但是,当我使用PUT方法时,params是JSON编码的并作为请求有效负载发送:
// {"params":{"heroId":123,"power":"Death ray"}}
$http.put("/api/test", {
params: { heroId: 123, power : "Death ray" }
})
Run Code Online (Sandbox Code Playgroud)
在使用PUT时,如何强制将参数添加到查询字符串中?