0

I have a Google form where people can submit books by author and book title. I would like to use this to retrieve the ISBN.

function atSubmitForm(e) {
  var formResponses = e.response;
  var itemResponses = formResponses.getItemResponses();
  var bookTitle = itemResponses[0].getResponse(); 
  var authorFirst = itemResponses[1].getResponse(); 
  var authorLast = itemResponses[2].getResponse(); 
 
  var url = "https://www.googleapis.com/books/v1/volumes?q=intitle:\"" + bookTitle + "\" inauthor:\"" + authorFirst + " " + authorLast + "\"" + "&country=CA";
  var urlEncoded = encodeURI(url);
  var response = UrlFetchApp.fetch(urlEncoded);
  var result = JSON.parse(response);
  var items = result.items;
  
  var item = items[0].volumeInfo;
  for (var i = 0; i < item.industryIdentifiers.length; i++) {
    var id = item.industryIdentifiers[i];
    if (id.type === "ISBN_13") {
      var isbn = id.identifier;
    } 
  }
}

This isn't the whole function, obviously, but the ISBN is what's giving me problems. It doesn't seem to be pulling the information I'm expecting. For example, the book Children of Time by Adrian Tchaikovsky will generate a urlEncoded = https://www.googleapis.com/books/v1/volumes?q=intitle:"Children+of+Time"+inauthor:"Adrian+Tchaikovsky"&country=CA and it will return an isbn = 9780316452496. I don't know where this ISBN comes from but it isn't listed on the urlEncoded page.

Similarly, On the Road by Jack Kerouac generates a urlEncoded = https://www.googleapis.com/books/v1/volumes?q=intitle:"On+the+Road"+inauthor:"Jack+Kerouac"&country=CA and then returns an isbn = 9780142437254, also not found on the previous page (i.e., urlEncoded).

Why doesn't it pull the first ISBN from these pages, or even from these pages at all?

Edit: For Tchaikovsky's Children of Time I was expecting isbn = 9781447273318. For Kerouac's On the Road I was expecting isbn = 9781101127575

Mjsk
  • 3
  • 3
  • Unfortunately, from your question, I cannot understand about your current issue and your goal. I apologize for this. Can I ask you about the detail of them? For example, what values of ISBN do you want to retrieve from your both samples in your question? – Tanaike Apr 04 '21 at 02:14
  • Sorry about that, and thanks for the reply. I've updated the question a bit with the expected isbns. – Mjsk Apr 05 '21 at 04:57
  • Thank you for replying and updating your question. – Tanaike Apr 05 '21 at 06:26

0 Answers0