Can an EDGE use the webDev module to connect with the HTTP method for a Standard project?

Hi everyone,
Lately, I have been looking for ways to enable SQL transactions from an Edge project to the database configured in a Standard project.
I know that the Edge panel does not have a database connection, but I would like to know if there is a way to do this with another tool.
I have installed the webDev module on both gateways and tried to do it using the HTTP POST method using an action performed of the button, but I haven't been able to. I get a 405 error.
I assume the method is not available in Edge Project, is that right? How can I do it?
Thank you for your suggestion.



Your edge project event script is pointing at localhost for the HTTP Post, which is, unless your standard project is on the edge panel, the wrong endpoint to target. Get the IP of the standard project gateway and use that instead.

Assuming the amount of data to send is small, consider using system.util.sendMessage or system.util.sendRequest on the edge server to send a message to the main server with the data to handle. This does not require the webdev module.

Also, webdev module is not required to make HTTP requests, just to handle them.

Screenshots are nice for context, but please also post code as preformatted text to help speed up troubleshooting for others, see Wiki - how to post code on this forum.

2 Likes

This.

If the amount of data is not small, you should reconsider whether Edge is the right platform.

1 Like

Now I'm trying it with system.util.sendMessage.
In the Edge panel, I add a new button with action performed with the following script:

payload = {
    "valor1": 1,
    "valor2": 2,
    "valor3": 3,
    "valor4": "hi",
    "valor5": "hi",
    "valor6": "hi",
    "valor7": "hi",
    "valor8": 4,
    "valor9": 10,
    "valor10": 111,
    "valor11": 200
    }
	response = system.util.sendMessage(
    project="IAPS",  
    messageHandler="a",
    payload=payload,
    scope="G")

And, in the project called IAPS into Ignition Standart Server, I add a new Message Handler into the Session Events called "a". With the following script:
*** I added a logger to verify the execution of the script. But I could omit it.*

logger = system.util.getLogger("myLogger")
logger.info("executed")

# Script: insertHandler
params = payload
query = """
	INSERT INTO recipes (userId,name,cuisine,difficulty,image,servings,cookTimeMinutes,prepTimeMinutes,reviewount,caloriesPerServing,rating) VALUES (?, ?,?,?,?,?,?,?,?,?,?)
	"""
system.db.runPrepUpdate(query, [params["valor1"], params["valor2"],params["valor3"],params["valor4"],params["valor5"],params["valor6"],params["valor7"],params["valor8"],params["valor9"],params["valor10"]],params["valor11"], database="test")
	

I don't have any errors, but it doesn't insert into the database either. What could it be?

You didn't define the remote servers argument, so the message is only being delivered to the edge gateway in your button script. I believe you need to use the server name as it appears in the GAN connection.

Also, your handler should be under 'Gateway Events', not 'Session Events'

2 Likes

Ryan, your suggestion to switch from httpPost to system.util.sendMessaget() made all the difference. I was able to successfully complete the data insertion from the Edge Panel to the Gateway thanks to your explanation. Really appreciate your help and the time you took to guide me!

1 Like