如何使用 REST url 和 api 创建容器?
How to Create a container by using REST url with api?
当提到环回页面时,有一个 API 来创建新容器,当我尝试使用那个 URL 创建一个容器时,它只显示
{"error":{"statusCode":404,"name":"Error","message":"There is no method to handle POST /Pictures%20%20?%20{%20%22name%22%20:%20Bhanu%20}","stack":"Error: There is no method to handle POST /Pictures%20%20?
create ()
{
var data = { "name" : this.getUserId() }
return new Promise((resolve,reject)=> {
this.http.post(this.apiUrl+'/Pictures'+ data,{
headers : new HttpHeaders().set('Content-type','application/json')
}).subscribe(res => {
resolve(res);
},(err) => {
reject(err);
});
});
}
预期结果应该是
{"name":"Bhanu2","size":4096,"atime":"2019-07-01T10:20:39.525Z","mtime":"2019-07-01T10:20:39.525Z","ctime":"2019-07-01T10:20:39.525Z"}
如果你想做一个 POST 请求,你不能只将请求正文添加到 url。或者可能是错字。 data
之前的 +
将是逗号 ,
.
this.http.post(this.apiUrl+'/Pictures',data,{
headers : new HttpHeaders().set('Content-type','application/json')
})
当提到环回页面时,有一个 API 来创建新容器,当我尝试使用那个 URL 创建一个容器时,它只显示
{"error":{"statusCode":404,"name":"Error","message":"There is no method to handle POST /Pictures%20%20?%20{%20%22name%22%20:%20Bhanu%20}","stack":"Error: There is no method to handle POST /Pictures%20%20?
create ()
{
var data = { "name" : this.getUserId() }
return new Promise((resolve,reject)=> {
this.http.post(this.apiUrl+'/Pictures'+ data,{
headers : new HttpHeaders().set('Content-type','application/json')
}).subscribe(res => {
resolve(res);
},(err) => {
reject(err);
});
});
}
预期结果应该是
{"name":"Bhanu2","size":4096,"atime":"2019-07-01T10:20:39.525Z","mtime":"2019-07-01T10:20:39.525Z","ctime":"2019-07-01T10:20:39.525Z"}
如果你想做一个 POST 请求,你不能只将请求正文添加到 url。或者可能是错字。 data
之前的 +
将是逗号 ,
.
this.http.post(this.apiUrl+'/Pictures',data,{
headers : new HttpHeaders().set('Content-type','application/json')
})