spring mvc - Angular 2 Http post call returning reponse status 406 error while calling java controller -


while doing http post call using angular2 java rest controller. keep getting exception saying response status : 406 - not acceptable.

here service.ts code

searchbac(vendorrequest : vendorrequest) : observable<vendorrequest>{     console.log('sending vendor request : ', vendorrequest);     if (typeof vendorrequest.bac != 'undefined' && vendorrequest.bac) {       console.log('bac certification url :' + this.bacurl);     }     let bodystring = json.stringify(vendorrequest); // stringify payload     console.log("bodystring: " +bodystring)     let headers      = new headers({ 'content-type': 'application/json' });     console.log("headers:" +headers.get('content-type'));     let options      = new requestoptions`enter code here`({ method : requestmethod.post, headers: headers.arguments }); // create request option      return this.http.post(this.bacurl,       bodystring,       options).map((res: response) => res.json())       .catch((error : observable<any>) => observable.throw(error));   } 

and javacontroller code

@requestmapping(value ="/vendor", method= requestmethod.post,             produces = mediatype.application_json_value)     public     @responsebody     vendorrequest getvendordetails(@requestbody vendorrequest vendorrequest) throws exception{         log.info("processing vendor-search request" +vendorrequest.getbaccode());         //vendorrequest vendorrequest = new vendorrequest();         int baccode = vendorrequest.getbaccode();         log.info(baccode+ "obtained request");         vendorrequest.setresponse("success");         log.info("vendorresponse object created , sending");         //objectwriter ow = new objectmapper().writer().withdefaultprettyprinter();         //string jsonstring = ow.writevalueasstring(vendorrequest);         return vendorrequest;     } 

please suggest me changes


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -