Coder Social home page Coder Social logo

Comments (5)

milokmet avatar milokmet commented on May 30, 2024 1

Great! How could I missed that? Thank you very much.

from fetchapp.

tanaikech avatar tanaikech commented on May 30, 2024

Thank you for your comment. Unfortunately, I couldn't understand about your situation from your comment. I apologize for this situation. So can you provide the detail information (flow and script) for completely replicating your situation? If there are some bugs, I would like to modify them.

from fetchapp.

milokmet avatar milokmet commented on May 30, 2024

Hello. Here is the code I tried to use the function main

function main() {
  var id = 'abcd';
  var fileBlob = DriveApp.getFileById(id).getBlob();
  
  var metadata = {
    name: "OCR-PDF-" + (new Date()).getYear(),
    mimeType: MimeType.GOOGLE_DOCS
  };
  
  var form = FetchApp.createFormData();
  form.append("metadata", Utilities.newBlob(JSON.stringify(metadata)));
  form.append("file", fileBlob);
  var url = "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart";
  
  var params = {
    method: "POST",
    headers: { Authorization: "Bearer " + ScriptApp.getOAuthToken() },
    body: form
    // muteHttpExceptions: true
  };
  
  var res = FetchApp.fetch(url, params);
  Logger.log(res);
}

And I got an exact error in slovak language:

Požiadavka zlyhala, pretože služba https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart vrátila kód 400. Skrátená odpoveď servera: { "error": { "errors": [ { "domain": "global", "reason": "parseError", "message": "Parse Error" } ], "code": 400, "messa... (ak chcete preskúmať celú odpoveď, použite možnosť muteHttpExceptions) (riadok 69, súbor Code, projekt FetchApp)

Translated: Request failed, because service https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart response code was 400. Response from server: { "error": { "errors": [ { "domain": "global", "reason": "parseError", "message": "Parse Error" } ], "code": 400, "messa...
line 69, file Code, project FetchAppp

I do not know how to debug code of FetchApp from a library, or how can I just copy the code to my project.

Thank you

from fetchapp.

tanaikech avatar tanaikech commented on May 30, 2024

Thank you for replying. From your replying, I think that I could correctly understand your situation.

Modification point:

  • For metadata, please add the mimeType of application/json.

So could you please modify as follows and try to run again?

Modified script:

From:

form.append("metadata", Utilities.newBlob(JSON.stringify(metadata)));

To:

form.append("metadata", Utilities.newBlob(JSON.stringify(metadata), "application/json"));

If this was not the solution, I apologize.

from fetchapp.

tanaikech avatar tanaikech commented on May 30, 2024

Welcome. I'm glad your issue was resolved.

from fetchapp.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.