Failed to convert server response to JSON when trying to call `getFile()` in typeScript

Hey i’m alway getting the error [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/files/jnbsq8f5sx8: [500 ] Failed to convert server response to JSON. I really tried everything, but somehow the error don’t resolve.

Here is my code, it is copied form the official docs.

let file = await fileManager.getFile(uploadResult.file.name);
      while (file.state === FileState.PROCESSING) {
        console.info(`File is ${file.state}...`);
        await new Promise((resolve) => setTimeout(resolve, 100));
        file = await fileManager.getFile(uploadResult.file.name);
      }

      if (file.state === FileState.FAILED) {
        throw new Error("File processing failed.");
      }
1 Like