google-apps-scriptgoogle-sheetsurlfetch

Exception: DNS error: (line 30, file "Code")


I'm attempting to use this spreadsheet:

 https://kennymcnett.com/domain-name-checker-in-google-sheets/

I obtained an API Key from RapidAPI.

However I am receiving the following error message:

 Exception: DNS error: https://domainr.p.mashape.com/v2/status?mashape-key=f23.....25c5&domain=undefined (line 30, file "Code")

Line 30 of the extension is:

var result = UrlFetchApp.fetch(url+domain);

All of the code in the extension:

// Works as of April 6, 2016

// domainr docs: http://domainr.build/docs/overview

// Get your free API key from https://market.mashape.com/domainr/domainr
// Create an application, get a key
// Put your key into the cell on the "Instructions" sheet


/* sample return JSON from domainr.p.mashape.com
* 
* https://domainr.p.mashape.com/v2/status?mashape-key=YOURKEYHERE&domain=testasfkljhsdf.com
* 
* Produces:
* 
* {"status":[{"domain":"testasfkljhsdf.com","zone":"com","status":"undelegated inactive","summary":"inactive"}]}
* 
*/

function domainLookup(domain) {
  if (domain == "") {
    return "N/A";
  }
  
  //Get the Key from cell A11 on the sheet named "Key"
  var key = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Instructions').getRange('key').getValue(); //range = named range of the cell with the API key in it
  
  //Submit to mashape
  var url = "https://domainr.p.mashape.com/v2/status?mashape-key=" + key + "&domain=";
  var result = UrlFetchApp.fetch(url+domain);
  var out = JSON.parse(result.getContentText());
  var answer = out.status[0].summary;
  
  //Interpret the answer
  if (answer == 'undelegated' || answer == 'inactive') {
    var finalAnswer = "Available";
  } else {
    var finalAnswer = "Nope";
  }
  
  //Logger.log(out);
  //Logger.log(finalAnswer);

  //Show the answer
  return finalAnswer;
}

These are the instructions in the spreadsheet:

For more detailed instructions and other information about this document, see the write-up:
http://kennymcnett.com/domain-name-checker-in-google-sheets/

Instructions

Step 1
Make a copy of this document into your own Google Drive. Then, don't change anything on this sheet except the API Key

Step 2
Get a domainr.com API key from mashape.com

Step 3
Paste your domainr API key from mashape.com below:
f236......................................b0725c5

Step 4
Go to the Domain Names sheet and have fun!

Bonus
If you want to see the script code, go to "Tools > Script editor..."For more detailed instructions and other information about this document, see the write-up:
http://kennymcnett.com/domain-name-checker-in-google-sheets/

Instructions

Step 1
Make a copy of this document into your own Google Drive. Then, don't change anything on this sheet except the API Key

Step 2
Get a domainr.com API key from mashape.com

Step 3
Paste your domainr API key from mashape.com below:
f236.........................................25c5

Step 4
Go to the Domain Names sheet and have fun!

Bonus
If you want to see the script code, go to "Tools > Script editor..."

Edit: Was able to solve this error by changing the URL to:

domainr.p.rapidapi.com

However after doing so I am now receiving a new error message:

Exception: Request failed for domainr.p.rapidapi.com returned code 403. Truncated server response: {"message":"You are not subscribed to this API."} (use muteHttpExceptions option to examine full response) (line 30).

Things I have done to so far:

  1. Verify that the API I am using is a free API. According to this URL the sub-domain I am using is for the free version of this api: https://domainr.p.rapidapi.com (free or non-commercial use) source: https://domainr.com/docs/api

  2. I verified that I don't have to input my credit card data to access free api's. According to this documentation, free api's don't require me to input credit card info to my RapidAPI account. `

`

FREE APIs

RapidAPI has thousands of FREE APIs. As the name suggests, you can try any of these APIs without providing credit card details. These APIs are clearly marked as FREE.

📘 Required Third-Party API Key

Occasionally you’ll need to acquire an API key or token from the provider’s website.

`

source: https://docs.rapidapi.com/docs/api-pricing


Solution

  • This is Eric from Domainr, try using domainr.p.rapidapi.com as the hostname (not mashape) -- RapidAPI recently deprecated the mashape hostname for some reason.