hi ,
Inputs are appreciated .Here is our use case, in our API we are receiving an attachment ,attachment can be of any type.API just has an invoke statement, we would be sending the attachment whatever we are receiving in apiconnect to our backend. When calling the backend We are receiving the below error from backend.
{
"timestamp": "2024-10-23",
"status": 400,
"error": "Bad Request",
"message": "required request part 'file' is not present",
"path": "*********"
}
when testing backend directly below is the curl command to be used which works.
curl -X POST "http://backendapi" -H "accept: application/json" -H "Authorization: Bearer xxx" -H "Content-Type: multipart/form-data" -F "file=@test.xml;type=text/xml"
how can apiconnect pass the attachment to backend, tried below in the gateway script before invoke which didn't work.at the run time how can we pass the attachment to the backend as above above curl command file type F "file=@test.xml;type=text/xml"
var formData = {
"file": {
"value": context.get('request.body'), // Path to the file
"options": {
"filename": "test.xml",
"contentType": "text/xml"
}
}
};
context.set('message.body',formData);
------------------------------
v k
------------------------------