Google Apps Script CodaAPI source code?

I would like to inspect the CodaAPI SDK for Google AppsScript if that’s possible.

I can’t seem to find it.

Ran into issues with it, need to pass the muteHttpExceptions to UrlFetchApp.fetch, but I’m not sure if I’m able to using options (it’s not working)

1 Like

Ah, found it! Google Drive: Sign-in


@Eric_Koleda / @oleg

I know the Coda API Apps Script library is autogenerated with OpenAPI, however, I found I had a problem where I couldn’t pass the muteHttpExceptions option to any of the functions.

You can see here that options can be provided to createDoc, but are then never used, instead a separate variable opts controls the invocation of UrlFetchApp.

My solution was to create my own fork of the Coda API which you can find here

The only difference is that by default my fetch opts contains muteHttpExceptions: true:

I need this because it turns out that Javascript’s try / catch blocks don’t allow you to discriminate exception types (because Javascript is somehow simultaneously the world’s worst and most widely used programing language… haha /rant).

There are three possible ways this could be resolved:

  1. Perhaps the OpenAPI spec isn’t quite complete and could be modified so that the opts available to UrlFetchApp.fetch can be passed to the options argument of getDoc, deleteDoc, etc…
  2. You could make the same edit I did to getBaseOpts, however, that would be a breaking change and therefore a full version increment. I think it’s a decent default, but it only solves the problem at hand, if there were other opts people wanted to pass it wouldn’t be available.
  3. You could modify the code manually so that the options provided to getDoc, deleteDoc etc are used in the opts argument. E.g. an intuitive invocation might be:
getDoc("aoeu123", {options: {muteExceptions: true}})

With this sort of implementation:

Thanks for the detailed update @Connor_McCormick1 ! It appears that opts was meant to capture optional parameters to the API endpoint, not options for the fetch call itself.

Can you provide some more background on which API error responses you needed to extract more information from?

1 Like

429 and 502 errors. In other words I just needed to be able to call result.getResponseCode()

1 Like