java - How set List in Spring Rest -


i'm developing first application uses spring rest, have class veiculo.class, agencia.class , contato.class. when created veiculo object, needs list contents agencia , spring generates correctly hypermedia my:

entity

@document public class veiculo{      @id     private string id;      @indexed(unique = true)     private string nome;     private string tipo;     @dbref     list<contato> contatos;      @dbref     list<agencia> agencias;  //getters , setters  } 

curl

daniela.morais@tusk:~$ curl http://localhost:8181/api/veiculos/55a50d42ccf2bc55501419d6 {   "nome" : "veiculo",   "tipo" : "tipo",   "_links" : {     "self" : {       "href" : "http://localhost:8181/api/veiculos/55a50d42ccf2bc55501419d6"     },     "contatos" : {       "href" : "http://localhost:8181/api/veiculos/55a50d42ccf2bc55501419d6/contatos"     },     "agencias" : {       "href" : "http://localhost:8181/api/veiculos/55a50d42ccf2bc55501419d6/agencias"     }   } } 

i need set list of agencia in path /55a512a7ccf2bc55501419dc/agencias (is veiculo attribute) how this? i didn't find example of need

daniela.morais@tusk:~$ curl http://localhost:8181/api/veiculos/55a50d42ccf2bc55501419d6/agencias {   "_links" : {     "self" : {       "href" : "http://localhost:8181/api/veiculos/55a50d42ccf2bc55501419d6/agencias"     }   },   "_embedded" : {     "agencias" : [ ]   } } 

when post happens

daniela.morais@tusk:~$ curl -i -x post -h "content-type: application/json" -d '{"agencias": [{"nome": "um"}]}' http://localhost:8181/api/veiculos/55a50d42ccf2bc55501419d6/agencias http/1.1 204 no content server: apache-coyote/1.1 x-content-type-options: nosniff x-xss-protection: 1; mode=block cache-control: no-cache, no-store, max-age=0, must-revalidate pragma: no-cache expires: 0 x-frame-options: deny date: tue, 14 jul 2015 14:31:14 gmt  daniela.morais@tusk:~$ curl http://localhost:8181/api/veiculos/55a50d42ccf2bc55501419d6/agencias {   "_links" : {     "self" : {       "href" : "http://localhost:8181/api/veiculos/55a50d42ccf2bc55501419d6/agencias"     }   },   "_embedded" : {     "agencias" : [ ]   } 

you need post /55a512a7ccf2bc55501419dc/agencias list of agencias in body.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -