CaroLab
03/28/2023, 12:43 PMvar headerObj = {
'Authorization': 'Bearer ' + tk,
'Accept': 'application/json',
'Content-Type': 'multipart/form-data; boundary=' + boundary
};
var bodyObj = boundary +
'\r\nContent-Disposition: form-data; name="file"; filename="test.png"\r\nContent-Type:image/png\r\n\r\n' +
myFile.getContents() + '\r\n' + boundary;
var response = <http://https.post|https.post>({
url: myUrl,
headers: headerObj,
body: bodyObj
});
But it does not work and I get a 422 error with message "the key 'file' is required to upload. Please check your body content"
Any idea ?battk
03/28/2023, 12:46 PMbattk
03/28/2023, 12:46 PMCaroLab
03/28/2023, 12:54 PMbattk
03/28/2023, 12:56 PMbattk
03/28/2023, 12:56 PMbattk
03/28/2023, 12:57 PMbattk
03/28/2023, 12:58 PMCaroLab
03/28/2023, 1:02 PMCaroLab
03/28/2023, 1:06 PMvar bodyObj = boundary +
'\r\nContent-Disposition: form-data; name="file"; filename="test.png"\r\nContent-Type:image/png\r\n\r\n' +
myFile.getContents() + '\r\n' + boundary;
looks like the postman body. Isn't it ?battk
03/28/2023, 1:07 PMCaroLab
03/28/2023, 1:08 PMbattk
03/28/2023, 1:11 PMbattk
03/28/2023, 1:11 PMCaroLab
03/28/2023, 1:13 PMbattk
03/28/2023, 1:14 PMCaroLab
03/28/2023, 1:14 PMbattk
03/28/2023, 1:18 PMCaroLab
03/28/2023, 2:15 PMCaroLab
03/28/2023, 2:17 PMbattk
03/28/2023, 2:19 PMbattk
03/28/2023, 2:19 PMbattk
03/28/2023, 2:20 PMbattk
03/28/2023, 2:20 PMbattk
03/28/2023, 2:21 PMCaroLab
03/28/2023, 2:28 PMbattk
03/28/2023, 2:29 PMbattk
03/28/2023, 2:29 PM