Coder Social home page Coder Social logo

tanaikech / fetchapp Goto Github PK

View Code? Open in Web Editor NEW
45.0 3.0 9.0 18 KB

This is a GAS library for creating and requesting the type of multipart/form-data using Google Apps Script. This library enhances Class UelFetchApp of Google Apps Script.

License: MIT License

JavaScript 100.00%
google-apps-script gas-library library developer-tools fetch multipart-formdata

fetchapp's Issues

Object for request is wrong. Please confirm formData again.

Hi! I was very happy for found it yor librarie but with a quick example, i've been receiving the same error message:

Error: Object for request is wrong. Please confirm formData again. at FetchApp.Fetch(Code:66:17) at fetch(Code:17:27)

The code I use is the one you provide in README, and I don't know what I am missing:

function main() {
  var folder = DriveApp.getFolderById('')
  var file = folder.getFilesByName('Salvoconducto Okima.pdf').next()
  var id = file.getId();
  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), "application/json"));
  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);
  console.log(res);
  // DriveApp.createFile(blob) // This comment line is used for automatically detecting scope for running this sample script.
}

I tried with the code of closed issue but still give me the same error :(
I hope you can help me!

(Sorry for my english)

support for multipart/related

Would you consider an option to support multipart/related? This would allot your app to be used with some of google's APIs such as cloud storage. It utilizes multipart/related which is very similar to multipart/form-data

ParseError while trying sample code

Hi I tried an example in readme file and I got this as response: { "error": { "errors": [ { "domain": "global", "reason": "parseError", "message": "Parse Error" } ], "code": 400

What should I do wrong? I just copy/paste your code. First I got error 403 insufficient privileges, but I created files with google app script. To authorize the application for write. But than I got code 400.

thanks

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.