json - Angular2 how to correct put request -


ok then, have single problem,

request url:http://.../rest/1.0/brand/test145 request method:put status code:500 internal server error remote address:...

request payload ok { "name": "test145" }

addbrand(name : string){     let body = json.stringify(name)     let url = this.baseurl + '/brand/' + name;     return this.http.put(url, { name }  ).     map(res => res.json()); }  addbrand(name:any){ if(!name){return;} this.brandservice.addbrand(name) .subscribe(     name => this.name.push(name),     error => this.errormesage = <any>error);  } 

but put should http://.../rest/1.0/brand/ , then, should request payload. when remove "name" from, doesn't load payload.

stricly put update, url should in format:

http://.../rest/1.0/brand/test145 last part unique id (you need indicate mean update)

if expect create record, should rather post http://.../rest/1.0/brand

but can choose deviate conventions. in order put .../brand payload { "name": "test145" } need to:

addbrand(name : string){     let body = json.stringify({ name: name })     let url = this.baseurl + '/brand'     return this.http.put(url, body ).     map(res => res.json()); } 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -