Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I pass JSON as well as File to REST API in JAVA?

My main question is how can I pass JSON as well as File to post request to REST API? What needs in Spring framework to work as client and wait for response by passing post with JSON and File?

Options:

  1. Do I need to use FileRepresentation with ClientResource? But how can I pass file as well as JSON?
  2. By using RestTemplate for passing both JSON as well as File? How it can be used for posting JSON as well as File?

Any other option is available?

like image 445
Kunal Shah Avatar asked Dec 19 '12 13:12

Kunal Shah


1 Answers

Sounds like an awful resource you're trying to expose. My suggestion is to separate them into 2 different requests. Maybe the JSON has the URI for the file to then be requested…

like image 126
Ray Avatar answered Nov 07 '22 09:11

Ray