How to sends multiple object over JSON from sitebricks client to sitebricks REST Service?

StackOverflow https://stackoverflow.com/questions/13007062

  •  13-07-2021
  •  | 
  •  

Question

Is it possible to sends two or more object simultaneously from sitebricks client to sitebricks service ?

For example, I have a Person Object and a JobApplication Object. Can I do something like this:

public class ApplicationStorage {

    @Post
    public void post(Person person, JobApplication job) {
        // ...
    }    
}

WebClient client = web.clientOf("service url") ..... // here how to send the two objects ? 
Was it helpful?

Solution

If sending two objects is a must, then create another object that is composed of the two objects that you wish to send over HTTP. Your JSON parser (ex: Jackson) will be able to serialize each of the first two objects into JSON, and set them as JSON attributes to your new object.

OTHER TIPS

You can send a List too, but this is not ideal as you have to mess about with Java Generics. The wrapper object is the best way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top