<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Network Request Error: for Post Call from Build apps to Document information extraction service in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/network-request-error-for-post-call-from-build-apps-to-document-information/m-p/13890790#M2038950</link>
    <description>&lt;P&gt;Hello Jagdeesh,&lt;/P&gt;&lt;P&gt;Thank you for reaching out to us. Are you still encountering the issue? Did you have a chance to share the screenshot of the console error (response from the API)?&lt;/P&gt;</description>
    <pubDate>Mon, 07 Oct 2024 11:49:36 GMT</pubDate>
    <dc:creator>Sankara1</dc:creator>
    <dc:date>2024-10-07T11:49:36Z</dc:date>
    <item>
      <title>Network Request Error: for Post Call from Build apps to Document information extraction service</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/network-request-error-for-post-call-from-build-apps-to-document-information/m-p/13871972#M2038948</link>
      <description>&lt;P&gt;I'm trying to Take Picture in Build apps and send image via POST Call to&amp;nbsp;Document information Extraction service using JS workflow function.&lt;BR /&gt;1. as Destinations Does not support Multipart content as mentioned in the&amp;nbsp;&lt;A href="https://community.sap.com/t5/technology-q-a/issue-with-sap-btp-destination-rest-api-integration-sap-build-apps/qaq-p/12817959" target="_blank"&gt;Issue with SAP BTP Destination Rest API Integratio... - SAP Community&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. with reference to&amp;nbsp;&lt;A href="https://community.sap.com/t5/technology-blogs-by-members/pdf-sending-to-rest-api-with-javascript-in-sap-build-apps/ba-p/13719916" target="_blank"&gt;PDF Sending to REST API with JavaScript in SAP Bui... - SAP Community&lt;/A&gt;,&amp;nbsp;&lt;A href="https://community.sap.com/t5/technology-blogs-by-members/explore-and-infuse-dox-capabilities-in-sap-btp-custom-applications/ba-p/13706066" target="_blank"&gt;Explore and Infuse DOX capabilities in SAP BTP cus... - SAP Community&lt;/A&gt;&lt;BR /&gt;I have written the Java script :&amp;nbsp;&lt;/P&gt;&lt;P&gt;try {&lt;BR /&gt;// Declare and initialize variables inside the try block&lt;BR /&gt;let url = inputs.url;&lt;BR /&gt;let file = inputs.file;&lt;BR /&gt;let Name = inputs.imageName;&lt;BR /&gt;let Token = inputs.Token;&lt;BR /&gt;let imPath = inputs.imagePath&lt;BR /&gt;// Fetch the image blob from the imagePath&lt;BR /&gt;let iPath = await fetch(imPath);&lt;BR /&gt;let blob = await iPath.blob();&lt;/P&gt;&lt;P&gt;// Prepare the form data&lt;BR /&gt;const formData = new FormData();&lt;BR /&gt;formData.append('file', blob, Name);&lt;/P&gt;&lt;P&gt;// Define the options for the request&lt;BR /&gt;var lv_options = {&lt;BR /&gt;"clientId": "default",&lt;BR /&gt;"documentType": "custom",&lt;BR /&gt;"schemaName": "Danfoss"&lt;BR /&gt;};&lt;BR /&gt;formData.append('options', JSON.stringify(lv_options));&lt;/P&gt;&lt;P&gt;// Make the POST request&lt;BR /&gt;const response = await fetch(url, {&lt;BR /&gt;method: 'POST',&lt;BR /&gt;headers: {&lt;BR /&gt;Accept: "application/json",&lt;BR /&gt;"X-Requested-With": "XMLHttpRequest",&lt;BR /&gt;Authorization: "Bearer " + Token&lt;BR /&gt;},&lt;BR /&gt;body: formData&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;if (response.ok) {&lt;BR /&gt;let data = await response.json();&lt;BR /&gt;return { id: data.id };&lt;BR /&gt;} else {&lt;BR /&gt;// Handle HTTP errors&lt;BR /&gt;alert("HTTP-Error: " + response.status);&lt;BR /&gt;}&lt;BR /&gt;} catch (error) {&lt;BR /&gt;// Handle errors that occur during fetch or JSON parsing&lt;BR /&gt;console.error("Error occurred:", error);&lt;BR /&gt;alert("An error occurred: " + error.message);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;3. Also Tried the Approach of Pick files from Build apps and replicated as it is mentioned in&amp;nbsp;&amp;nbsp;&lt;A href="https://community.sap.com/t5/technology-blogs-by-members/pdf-sending-to-rest-api-with-javascript-in-sap-build-apps/ba-p/13719916" target="_blank"&gt;PDF Sending to REST API with JavaScript in SAP Bui... - SAP Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;But still i'm Getting the Network Request Failed error. i don't know where i'm going wrong&lt;BR /&gt;Can anyone Please help me with this.&lt;BR /&gt;Thanks in Advance.&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/72"&gt;@Dan_Wroblewski&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/5123"&gt;@EvgeniyGorbunov&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2024 07:36:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/network-request-error-for-post-call-from-build-apps-to-document-information/m-p/13871972#M2038948</guid>
      <dc:creator>Jagadeesh21</dc:creator>
      <dc:date>2024-09-20T07:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: Network Request Error: for Post Call from Build apps to Document information extraction service</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/network-request-error-for-post-call-from-build-apps-to-document-information/m-p/13873418#M2038949</link>
      <description>&lt;P&gt;It would help to see the errors you get, in console, response from API.&lt;/P&gt;&lt;P&gt;When I send to DMS, which I am assuming is similar, I do it slightly differently, and don;t do all the blob stuff.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const {url, fileObj, token} = inputs

try {
  const formData = new FormData()

  const fileData = {
    uri: fileObj.path,
    size: fileObj.size,
    type: fileObj.mimeType,
    name: fileObj.name
  }
  formData.append('media', fileData)
  formData.append('cmisaction', 'createDocument')
  formData.append('propertyId[0]', 'cmis:objectTypeId')
  formData.append('propertyValue[0]', 'cmis:document')
  formData.append('propertyId[1]', 'cmis:name')
  formData.append('propertyValue[1]', fileObj.name)
  formData.append('succinct', true)
  formData.append('filename', fileObj.name)
  formData.append('includeAllowableActions', true)

  //------

  const response2 = await fetch(url, {
    method: "POST",

    headers: {
      "Authorization": "Bearer " + token,
      "Accept": "application/json",
      "DataServiceVersion": "2.0",
      "Content-Type": "multipart/form-data"
    },
    body: formData
  })
  return {id: response2}
  
} catch (error) {
  console.log(JSON.stringify(error))
  const errorObj = {
    code: "9",
    message: "something went wrong",
    rawError: error
  }
  return [1, errorObj]
}&lt;/LI-CODE&gt;&lt;P&gt;The fileObj is just the output of the pick files flow function:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;outputs["Pick files"].files[0]&lt;/LI-CODE&gt;&lt;P&gt;Don't know if this would work for you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 22 Sep 2024 15:52:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/network-request-error-for-post-call-from-build-apps-to-document-information/m-p/13873418#M2038949</guid>
      <dc:creator>Dan_Wroblewski</dc:creator>
      <dc:date>2024-09-22T15:52:31Z</dc:date>
    </item>
    <item>
      <title>Re: Network Request Error: for Post Call from Build apps to Document information extraction service</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/network-request-error-for-post-call-from-build-apps-to-document-information/m-p/13890790#M2038950</link>
      <description>&lt;P&gt;Hello Jagdeesh,&lt;/P&gt;&lt;P&gt;Thank you for reaching out to us. Are you still encountering the issue? Did you have a chance to share the screenshot of the console error (response from the API)?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2024 11:49:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/network-request-error-for-post-call-from-build-apps-to-document-information/m-p/13890790#M2038950</guid>
      <dc:creator>Sankara1</dc:creator>
      <dc:date>2024-10-07T11:49:36Z</dc:date>
    </item>
  </channel>
</rss>

