API Workflow: Add Rows to Another Table

I’m currently testing out a batch add row workflow using a webhook.

I had previously been adding a selection of rows using the add new row to another table action. I have found this was taking considerable sync time and disturbing other app functionality when applied.

I have been trying to use the workflow with the following process;

  1. The rows are selected and an action to update the date/time of the rows updated
  2. The condition the workflow is checking is whether or not the date/time value has been changed from previous version using this formula

AND(ISNOTBLANK([Date/Time Requested]),[_THISROW_BEFORE].[Date/Time Requested]<>[_THISROW_AFTER].[Date/Time Requested])

  1. This then triggers the workflow to add row using the following

  1. After the workflow adds the row the rows should update the status from ‘To be Requested’ to ‘Requested’
    image

This is taking even longer than the previous action and I’m receiving this error in the log.
"Webhook HTTP post request failed with exception The remote server returned an error: (400) Bad Request. "

I can’t seem to find an appropriate action to trigger the workflow. Is there someway to know or record when the action is fired?

I’ve never had any luck with those ‘Preset’ AppSheet:__ settings. It was too buggy when it was first released so I just use ‘Custom’ and insert the endpoint URL manually.

I decided to give it another try this morning and created an AppSheet: Add Row webhook, then ran a few tests.

  • Execution times were excessive (~60 seconds)
  • 400 Error on one attempt ( “Errors”: “Error: AppSheet Webhook action depth reached”)

I would suggest trying the ‘custom’ webhook, or maybe see if the new AppSheet Automations would work.

1 Like

Thanks for the help, I’m still receiving the same bad request error in the log with the custom webhook

"Webhook HTTP post request failed with exception The remote server returned an error: (404) Not Found. "

Is it something to do with the URL? I wasn’t sure I had done that properly is there a particular URL I should be inputting

This is the JSON text
image

I think the SELECT formula thats causing the issue, I don’t want the entire table to be checked just the selected items that the action is applied to so its timing out

Is that the default template that was generated by AppSheet? Maybe just change the TRUE to filter out for your ‘selected items’.


The 400 error is a separate problem, though. Is the API enabled, under Manage Integrations?

Yes the API is enabled.

Okay so remove the TRUE or replace it with the condition formula?

If you read the whole table like you have, and the table is big one, it could cause this as well.

@Aleksi I have a question.

Recently I’ve been seeing an increasing amount of people making use of the API for operations that could be achieved using actions; so it’s got me wondering?

What is the main differences between using a webhook to add these rows vs. an action?

To me, it seems that the webhook operation from this post (and all the others I’m referring to) could easily be switched to a reference action that creates the rows - and perhaps reduce some of the “coding” necessary.

2 Likes

Using the action to create rows in another table is taking significant sync time e.g. 18.5 minutes to do 46 syncs, some syncing is taking over an hour due to the large number of items they have selected to add.

We have noticed a pattern between users performing this action making the whole app and in some cases other apps under the same datasource, unfunctional. We receive an error “Too many requests being sent”.

Thats why we have been looking into API now

2 Likes

A very good reason. (^_^)

Perhaps there is a way to adapt your data schema to reduce the number of records necessary?

I tried switching the TRUE statement with the condition

image

But I’m still seeing this in the log image

any idea where I’m going wrong?

1 Like

At the minute the Table I’m taking the rows from (Material Take Off Table) has 15,327 rows

The Table I’m adding them to (Order Details Table), contains 16,789 rows.

Does that seem like a lot for this action to run smoothly?

1 Like

Yeah… that’s a fair amount of records to deal with.

  • Do you use slices to create subsets of data?

For example:

image

First

I’m always advocating against special characters in column names, as_well_as_removing_spaces_for_underscores.

Just throwing it out there, that forward slash inside the column name could cause some problems as things get more and more involved. If you ever port this over to a SQL, it will complain about that in a big way; just FYI.


In this formula, you’ve got the condition isnotblank([Date/Time Requested])

I would split that off into a slice

  • this way when you do a SELECT(), instead of doing it over the whole table, you can use your subset and “lighten the load.”

This is probly the most forgotten, or unknown, thing to do with AppSheet apps. The source of almost everyone’s problems is due to some sort of SELECT() they’ve got running somewhere - and it’s taking FOR-EV-ER. By creating data subsets you offset when calculations are done, greatly increasing the efficiency of everything invovled.

3 Likes

As Sarah explained, if you have more than just few records to add/update, it doesn’t matter. But if you have lot of, it’s better to bulk calculate them for example with the Start: & End expression.

4 Likes

If the formula generates a blank list, it will produce an error… though if I remember this correctly, it gives “Bad request” rather than 404.

2 Likes

I created a slice with the condition isnotblank([Date/Time Requested])

I tried to add 4 records, which was 4 syncs that ran for about 1 minute. But nothing added to the Order Details table due to this error from the editor

image

There were only 23 rows that met the slice condition, so not sure where I’m going wrong.

I think the workflow itself just isn’t adding to the correct table :confused:

  1. 200 Success
  2. 400 Bad Request
    a. The Application Access Key is missing.
    b. The AppId is missing.
    c. The Post body contains invalid data.
  3. 403 Forbidden
    a. The Web API is not enabled for this application.
    b. The Application Access Key is invalid.
    4. 404 Not Found
    a. The application specified by the AppId cannot be found.
  4. 500 Internal Server Error
    a. An unexpected error occurred.

In view of the error code, it sounds the issue is associated with accesskey or something.

Is your integration setting and turned on and the fresh access key available?

3 Likes

Yes I think so

image

Create new access key and try a shot with it

2 Likes