Hi,
I am trying to create and deploy a virtual service through REST Invoke API in DevTest 10.1 through nodejs request. I am facing issue in passing File path in formData. I have tried both the file & fileURI approaches and getting the below responses. Please suggest what could be wrong here?
using 'fileURI' parameter:
var options = { method: 'POST',
url: 'https://<<host>>:<<port>>/api/Dcm/VSEs/VSE/actions/createService',
headers:
{ 'postman-token': '9e46e0fb-8bb0-8225-29bc-0dff7e62d1d9',
'cache-control': 'no-cache',
authorization: 'Basic dsdsgds45365#345436',
'content-type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' },
formData: { fileURI: 'file:///D:/ProjectFolder/ProjectSubFolder/Project/RRPairs.zip' } };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
Result:
com.itko.lisa.invoke.api.exception.BadRequestException: Can't open file:///D:/ProjectFolder/ProjectSubFolder/Project/RRPairs.zip please check again
using 'file' parameter:
var options = { method: 'POST',
url: 'https://<<host>>:<<port>>/api/Dcm/VSEs/VSE/actions/createService',
headers:
{ 'postman-token': '9e46e0fb-8bb0-8225-29bc-0dff7e62d1d9',
'cache-control': 'no-cache',
authorization: 'Basic dsdsgds45365#345436',
'content-type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' },
formData: { file:
{ value: 'fs.createReadStream("D:/ProjectFolder/ProjectSubFolder/Project/RRPairs.zip")',
options: { filename: 'D:/ProjectFolder/ProjectSubFolder/Project/RRPairs.zip', contentType: null } } }};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
Result:
Response Body is blank and virtual service is not created.