JSON Code to be corrected in Bubble's API Connector

Hi,
For the below code I get error: Raw response for the API
Status code 400
{“error”:true,“status”:400,“message”:“Invalid input url. Please set url to the link accessible without authentication or upload a file to API and use as a input link for other APIs.”,“credits”:0,“duration”:0,“errorCode”:400,“remainingCredits”:10000}

{
“script”: {
“description”: “Access custom state and call API with file URLs”,
“code”: [
“// Access the custom state from the UploadRFPDocument element”,
“const fileUrlsJson = document.querySelector(‘#UploadRFPDocument’).getAttribute(‘data-custom-state-fileUrls’);”,

  "// Log the JSON to ensure it's correct",
  "console.log(fileUrlsJson);",
  
  "// Parse the JSON string to an array (ensure it's valid JSON)",
  "let fileUrls;",
  "try {",
  "    fileUrls = JSON.parse(fileUrlsJson);",
  "} catch (error) {",
  "    console.error('Error parsing JSON:', error);",
  "    return; // Exit if JSON parsing fails",
  "}",
  
  "// Iterate over each URL and call the API",
  "fileUrls.forEach(fileUrl => {",
  "  // Prepare the API payload",
  "  const payload = {",
  "    \"url\": fileUrl // Adjust to the required field name by the API",
  "  };",
  
  "  // Make the API call (adjust function name and payload structure as needed)",
  "  ExtractTextFromRFP.Process_Single_PDF(JSON.stringify(payload)); // Ensure the payload is sent as a JSON string",
  "});"
]

}
}

I okay the same error for the pdf.co api. Did you find a fix?

This topic was automatically closed after 70 days. New replies are no longer allowed.