CURL post file data and additional parameters

Problem: Post file data & additional parameters to REST API through curl or command line

Solution:

curl -F ‘file=@{LOCAL_FILE_LOCATION}’ http://localhost:8080/api/data/add -F “info={“p”:false,”subtype”:”BT”,”userid”:”abcd@gmail.com”}”

Eg Java API to consume the above curl data:

@RequestMapping(value = "/add", method = RequestMethod.POST)
public ResponseEntity<String> addData(@RequestParam("info") String info, @RequestParam("file") MultipartFile file) {

Leave a comment

Your comment

*