Network Request Error: for Post Call from Build apps to Document information extraction service

I’m trying to Take Picture in Build apps and send image via POST Call to Document information Extraction service using JS workflow function.
1. as Destinations Does not support Multipart content as mentioned in the Issue with SAP BTP Destination Rest API Integratio… – SAP Community 

2. with reference to PDF Sending to REST API with JavaScript in SAP Bui… – SAP CommunityExplore and Infuse DOX capabilities in SAP BTP cus… – SAP Community
I have written the Java script : 

try {
// Declare and initialize variables inside the try block
let url = inputs.url;
let file = inputs.file;
let Name = inputs.imageName;
let Token = inputs.Token;
let imPath = inputs.imagePath
// Fetch the image blob from the imagePath
let iPath = await fetch(imPath);
let blob = await iPath.blob();

// Prepare the form data
const formData = new FormData();
formData.append(‘file’, blob, Name);

// Define the options for the request
var lv_options = {
“clientId”: “default”,
“documentType”: “custom”,
“schemaName”: “Danfoss”
};
formData.append(‘options’, JSON.stringify(lv_options));

// Make the POST request
const response = await fetch(url, {
method: ‘POST’,
headers: {
Accept: “application/json”,
“X-Requested-With”: “XMLHttpRequest”,
Authorization: “Bearer ” + Token
},
body: formData
});

if (response.ok) {
let data = await response.json();
return { id: data.id };
} else {
// Handle HTTP errors
alert(“HTTP-Error: ” + response.status);
}
} catch (error) {
// Handle errors that occur during fetch or JSON parsing
console.error(“Error occurred:”, error);
alert(“An error occurred: ” + error.message);
}

3. Also Tried the Approach of Pick files from Build apps and replicated as it is mentioned in  PDF Sending to REST API with JavaScript in SAP Bui… – SAP Community

But still i’m Getting the Network Request Failed error. i don’t know where i’m going wrong
Can anyone Please help me with this.
Thanks in Advance.

@Dan_Wroblewski @EvgeniyGorbunov 

Scroll to Top