Gateway Scheduled Script - API Error

Goal:

To read with an API and then write updates to a different API through a schedule on the gateway.

Problem:

Script will run in the script console but does not complete past the API in the Scheduled Gateway Event.

Script Console:

Code Block:

Results:

image

Gateway Event - Scheduled

Script

Results:

Please post code - not pictures of code (unless the context is important, in which case post both) so we can copy them for testing or modification. Please see Wiki - how to post code on this forum.

1 Like

Don't logger.error("some error" + str(e) - you lose the except trackback and cause information, the most valuable part.

Use logger.error("Some error", e), so that the exception goes through the automatic logging machinery and captures the stacktrace.

6 Likes

Additionally, stuff this script into a Project Library Script and put the initialization of the httpClient outside of any function definitions so you can reuse the same client instead of spawning a new one every time the function runs.

Something along the lines of:

import json
logger = system.util.getLogger("SmartSheetUpdate")

SHEET_HEADERS = {}
SHEET_URL = "https://some url here"

sheetClient = system.net.httpClient()


def abc(payload):
	""" """
	
	response = sheetClient.get(url=SHEET_URL, headers=SHEET_HEADERS)
2 Likes

Once in a project library, you may want to install my Integration Toolkit and do this:

@system.util.runInGateway
def abc(payload):
	...

... so you can call it in the designer but it will run in the gateway. And you'll likely be able to see what is wrong.

(Designer scope is a variant of Vision Client scope--not related to Gateway Scope at all.)

1 Like

Where do I find this integration toolkit?

I did this definitely much easier

And then to my Module Sales page. (But this one is free.)