[英]How to build a query url parameters for the nested REST API?
I have the following REST API (json object) for search and I should build a POST request in the URL, what what be the url parameters for the following REST API? 我具有以下用于搜索的REST API(json对象),我应该在URL中构建POST请求,以下REST API的url参数是什么? Just because it's nested I don't know how to build the url where to include question mark or equals signs.
只是因为它是嵌套的,所以我不知道如何在包含问号或等号的位置构建url。
http://localhost:63020/api/search ....? http:// localhost:63020 / api / search ....?
{
"offset": 0,
"batchsize": 10,
"search": {
"scope": [2,3,32],
"type": "basic",
"text": {
"value": "test*",
"fields": [
"subject", "body"
]
},
"age": {
"unit": "d",
"amount": 365
},
"hasattachments": false,
},
"facet": "messagehits",
}
由于您要使用发布请求,因此无需修改URL( https://www.w3schools.com/tags/ref_httpmethods.asp ),只需将其作为文档正文传递,并在服务器端进行处理即可。
Ok so figured it out in Anagular 4 I am using HTTP client module, what I did I just passed the whole object as a parameter and I got a response back, simple as that, see the following code: 好的,所以可以在Anagular 4中弄清楚了,我正在使用HTTP客户端模块,我只是将整个对象作为参数传递给我,然后返回了响应,就这么简单,请参见以下代码:
sampleSearch(){
this.http.post('/api/search/', {
"offset": 0,
"batchsize": 10,
"search": {
"scope": [2,3,32],
"type": "basic",
"text": {
"value": "test*",
"fields": [
"subject", "body"
]
},
"age": {
"unit": "d",
"amount": 365
},
"hasattachments": false,
},
"facet": "messagehits",
}
).map(data => data).subscribe(
res => {
console.log(res);
},
err => {
console.log("Error occured");
}
);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.