Hello All,
I’m facing a problem, here it is
I have a server , wiremock (for callback) and postman.
My server send to wiremock an audio file, with postman I check this request and I want to verify the audio file by resending this audio to another server.
with postman I do
POST {{WIREMOCK_URL}}/__admin/requests/find
Body
{
“method”:“POST”,
“urlPathPattern”: “/incoming_prompt”
}
and the response contains:
A json like this
{
"requests" : [ {
"url" : /incoming_prompt",
"absoluteUrl": "...",
"method" : "POST",
...
"headers" :{
...
"Content-Type" : "multipart/form-data;boundary=cbrrYFpJeVLnZJdkwuvvW93PJgVWEfzgUKSYu;charset=UTF-8"
},
...
"bodyAsBase64": ".....",
"body": ""body" : "--cbrrYFpJeVLnZJdkwuvvW93PJgVWEfzgUKSYu\r\nContent-Disposition: form-data; name=\"recordFile\"; filename=\"VXI00009d42O0ybpO\"\r\nContent-Type: audio/x-wav\r\nContent-Length: 11450\r\n\r\nRIFF�,\u0000\u0000WAVEfmt .....",
....
}
So in body I have the audio file in multipart
I want to make another put request to resend this file
How can I do that please?
I’ve already tried:
I tried what I see here in postman example
In tests part
var jsonData = pm.response.json();
var body = jsonData.requests[0].body;
setTimeout(() => {
pm.sendRequest({
url: 'https://wiremock/__admin/files/recorded.wav',
method: 'PUT',
header: 'Content-Type:audio/x-wav',
encoding: 'binary',
body: {
mode: 'form-data',
raw: body
}
}, function (err, res) {
console.log(res);
});
}, 5000);
doesn't work
Or may be I have to write as a file before to resend it something like (does not work)
var jsonData = pm.response.json();
var myBody = jsonData.requests[0].body;
let opts = {
requestName: request.name || request.url,
fileExtension: 'wave',
mode: 'writeFile', // Change this to any function of the fs library of node to use it.
uniqueIdentifier: 'waddup',
responseData: myBody,
options: {
encoding: 'binary'
}
};
setTimeout(() => {
pm.sendRequest({
url: 'https://wiremock/__admin/files/recorded.wav'',
method: 'PUT',
header: 'Content-Type:audio/wav',
encoding: 'binary',
body: {
mode: 'raw',
raw: myBody
}
}, function (err, res) {
console.log(res);
});
}, 5000);
Thanks very much for your help
Jean