Fetch JSON with 1 click [v3 - Better POST support]

Hi all, I’ve just updated my doc that enables you to get json data given a url. Now it supports POST and PUT requests. You need to provide the body and headers as json objects in the respective columns.

You can integrate it into your own doc just by copying and pasting the Main and Engine sections.

All instructions inside the doc itself: Fetch JSON v3

Original thread:

Let me know if it worked for you.

Updates

v3: 
Added option to stringify body. (Some APIs need it, some don't).
Fixed time outs and treated exceptions. Much more reliable now.

v2: 
Added POST support
9 Likes

wow that looks like alot of work, looks awesome though!

Cool use of Google Apps Script to do the dirty work of hitting the external endpoint! We hope to have something like this native to Coda in the future, but it requires a bit of work to implement in a secure way (something that Google Apps Script has already built).

3 Likes

Thanks @Paul_Hitchenson, it does look complicated but hopefully if you follow the steps it should only take a few clicks to set it up.

@Dalmo_Mendonca thanks for this information. I want to integrate my doc with a third party app and I have a question I was hoping you could kindly answer. The app I’m trying to integrate with, has a header authentication. They ask for Authorization: SECRETKEY (secretkey being the API).
Can I include this in the Main section under headers? If so, which is the format I should use to insert Authorization: SECRETKEY?

Thanks a lot for your help

Hi,
First of all, I want to thank @Dalmo_Mendonca for creating this DOC. It’s really cool. I’m using it and it works beautifully.
I always try to understand the inner work of docs like this, so I can learn.
What caught my attention was the formula of “Check and Update” in the Engine Table.
Instead of:

If(thisRow.[New Response].IsNotBlank(),
runactions(
thisRow.ModifyRows(thisRow.Response,thisRow.[New Response]),
thisRow.Request.ModifyRows(Response,thisRow.Response),
thisRow.ModifyRows(thisRow.Done,True())
),
thisRow.[Retry C&U]
)

shouldn’t it be:

If(thisRow.[New Response].IsNotBlank(),
runactions(
thisRow.ModifyRows(thisTable.Response,thisRow.[New Response]),
thisRow.Request.ModifyRows(Response,thisRow.Response),
thisRow.ModifyRows(thisTable.Done,True())
),
thisRow.[Retry C&U]
)

If so, why does it work the way it is?

There’s no difference really how you enumerate columns in a ModifyRows. It can be TableName.ColumnName or thisRow.ColumnName if you’re modifying thisRow. It works either way. I suspect that’s because the code is only looking at the column ID part of the reference.

I’ve noticed that autocomplete suggests thisRow.ColumnName in thisRow.ModifyRows() context.

Hi @Paul_Danyliuk.
Still I find it very confusing specially for people who are learning.
ThisRow.column is not a column at all and you shouldn’t be able to use it in this case, at least from my standpoint.
The funny thing is the [View of a table].Column is a column and you can’t use it as argument for ModifyRows. It took me a while to learn that.

1 Like

I have really enjoyed digging into the “Fetch JSON v3” example doc posted by @Dalmo_Mendonca. It is just amazing what is able to be done in Coda.

Before I spend time customizing it to my needs I thought I should check with the community. @oleg mentioned some possible changes to Coda itself.

Have there been and updates to this doc or changes to the preferred approach since it was first published over a year ago?

We don’t have anything to share on this front with regards to changes in Coda, so you’ll have to continue to rely on an external system like Google Apps Script to do the heavy lifting.

Trying to use this, but I’m consistently getting the error:

Request failed for https://coda.io returned code 404. Truncated server response: {"statusCode":404,"statusMessage":"Not Found","message":"Not Found"} (use muteHttpExceptions option to examine full response)
    at updateRow(Coda:376)
    at doGet(Code:109)

Not sure what the issue is, just wanted to report the failure. I have tried twice to follow all steps from the beginning to make this work.

Following up on this. Has anyone recently tried this approach and gotten it to work?

@oleg does this still work for you?

@oleg Following up on this. I don’t know if this thread still gets much traffic, but this is something I’d like to implement in the near future.

1 Like

Hi, @cnr
I have a Doc with this approach implemented and I can assure you, it works perfectly fine. :smiley:

Huh… I must be doing something wrong.

All you did was follow the steps in the doc?

Yes.
I just followed the instructions.
Mine is heavily modified to fit my needs now.
I can’t really help you more than that. I only have basic knowledge of JavaScript and API.
Sorry about that.

1 Like

Hi @cnr, I’ve never attempted to run @Dalmo_Mendonca’s code so I’m not sure why you’re getting a 404. You’ll need to make sure you’re running the latest version of the Google Apps Script library though, per instructions on https://coda.io/api. It’s possible that the original one is still hitting the old v1beta1 endpoints.

Would be great that Coda had an easy function like LoadJSON(“url”)
So then we could do ParseJSON(LoadJSON(“url”))

That would make the things so easy…

5 Likes

same here… getting a 404. tried with both old editor and new. including with v8. throws an error from the codaapi library that i cant access.

adding to @Irfan_Khan and @cnr that I too am getting a 404 on every try. Followed directions from doc (apiKey, token, project URL, etc). Anything else to check?