Hi all,
I'm trying to use an external python script to call the appsheet API and update a single value in a table.
The update is failing silently (i.e. the API call is reported as successful, but the field I want to update is not updated). When I call the API directly via curl to POST the exact same JSON payload to the Appsheet API, it works.
I realise this could well be a python issue rather than appsheet itself, however I have used the same python code to successfully update a different appsheet table in the same appsheet app (though with a different JSON payload of course). So I'm struggling to troubleshoot why it fails only on this table, and was hoping someone could suggest where i'm going wrong.
The table I need to update is called "Patient Messages". It has no security filters on it.
It has a key field "Message ID"
I want to update another field, "message_sid" - this has no appsheet formulas, it's type is "Text".
The python script gets the value of message_sid from an external system (Twilio) as a callback when a whatsapp message is sent via Twilio.
The JSON I'm posting to the Appsheet API is valid - an example is below:
I don't think this can be an authentication issue, as there are no errors to suggest this, and as mentioned the update does work if I call the API directly on the command line with curl (using exactly the same JSON payload - I have dumped this from the python script just before it calls the appsheet API, so I know it is identical).
I've compared the API log entry for the failed update via the python script, and the successful one via curl. They are identical. But the message_sid field is only updated in the latter case with curl, even though both report as successful in the logs with no errors.
Any ideas on how I can troubleshoot this further?
Thanks
Joe
Solved! Go to Solution.
@JoeMcFadden wrote:
the API call is reported as successful, but the field I want to update is not updated
It sounds like you're saying that AppSheet's response to the API call reflects the updated value, but the updated value doesn't persist in the data source. That sounds like the value in the data source may be subsequently overwritten via some other automation--perhaps triggered by the API-based edit. Review the edit history of the table row or individual cell. If the data is in Sheets, that's really straightforward.
@JoeMcFadden wrote:
the API call is reported as successful, but the field I want to update is not updated
It sounds like you're saying that AppSheet's response to the API call reflects the updated value, but the updated value doesn't persist in the data source. That sounds like the value in the data source may be subsequently overwritten via some other automation--perhaps triggered by the API-based edit. Review the edit history of the table row or individual cell. If the data is in Sheets, that's really straightforward.
Hi @dbaum, it is not that it doesn't persist - it doesn't appear in the data source (which is Sheets) at all, despite being present in AppSheet's response to the API Call.
I double-checked this in the version edit history of the row and cell as you suggested - the value is never written to the data source.
There is only one automation on this table, which is triggered by additions only, not updates. It is not being triggered when I test the update, so I don't think this can be the cause. But not really sure what to try next to troubleshoot the problem.
How frustrating! If you're confident that there's not something basic being overlooked (e.g., I assume you're sure the API indeed calls the intended app and table--for instance, it's not calling a dev version while you're looking for the updates in a prod version), then it sounds like you should contact AppSheet Support.
I did eventually find the issue, and @dbaum was correct, it was caused by an automation!
I had simplified my description of the problem originally, and missed out what ended up being the critical context.
The external python script is itself called by an Appsheet bot. This bot updates another field in the table with a set row values data action. It was this step that was overwriting the message_sid field with a null value. What confused me was the updated message_sid cell is not present in the version history for the google sheet. Solved now though - thank you!
User | Count |
---|---|
16 | |
7 | |
6 | |
4 | |
3 |