Ad
How To Create A Container By Using REST Url With Api?
When referring to the loopback page ,there is an API to create new container,when i am tring to create a container using that URL, all it is showing is
{"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);
});
});
}
the expected result should be
{"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"}
Ad
Answer
If you want to do a POST request, You cannot just add the request body to the url. Or maybe it is a typo. The +
before the data
will be comma ,
.
this.http.post(this.apiUrl+'/Pictures',data,{
headers : new HttpHeaders().set('Content-type','application/json')
})
Ad
source: stackoverflow.com
Related Questions
- → Maximum call stack exceeded when instantiating class inside of a module
- → Browserify api: how to pass advanced option to script
- → Node.js Passing object from server.js to external modules?
- → gulp-rename makes copies, but does not replace
- → requiring RX.js in node.js
- → Remove an ObjectId from an array of objectId
- → Can not connect to Redis
- → React: How to publish page on server using React-starter-kit
- → Express - better pattern for passing data between middleware functions
- → Can't get plotly + node.js to stream data coming through POST requests
- → IsGenerator implementation
- → Async/Await not waiting
- → (Socket.io on nodejs) Updating div with mysql data stops without showing error
Ad