cURL to WebClient or RestTemplate with file

Viewed 28

Given the postman and cURL samples below, how can I code this with Java WebClient or RestTemplate? I'm unable to figure out how to construct the body with the correct headers, file, content-type etc..

Postman

Here is the cURL

curl --location --request PUT '[url]' \
--header 'authorization: Bearer [token]' \
--form 'fileData="[json]"' \
--form 'file=@"/C:/path/file.json"'

Here is the Raw HTTP request

PUT [url]
authorization: Bearer [token]
User-Agent: PostmanRuntime/7.29.2
Accept: */*
Cache-Control: no-cache
Host: [host]
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Type: multipart/form-data; boundary=--------------------------821418838150769919184719
Content-Length: 121986
 
----------------------------821418838150769919184719
Content-Disposition: form-data; name="fileData"
[json]
----------------------------821418838150769919184719
Content-Disposition: form-data; name="file"; filename="file.json"
<file.json>
----------------------------821418838150769919184719--
 
HTTP/1.1 200 OK
Date: Sat, 27 Aug 2022 01:33:15 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Content-Encoding: br
Vary: Accept-Encoding
Request-Context: appId=cid-v1:55ff528b-00c0-4656-b479-7f1d61e8f50b
Strict-Transport-Security: max-age=86400; includeSubDomains; preload
 
[json response]
0 Answers
Related