Call a webhook from Code snippet

Questions about and code samples for automation process code snippets within Select.
Post Reply
codvisor
Posts: 6
Joined: Wed Nov 09, 2022 12:52 pm

Call a webhook from Code snippet

Post by codvisor »

Hi,

Quite new to code snippets.
I am trying to call a webhook (for example: "https://hook.mine.com/fsgbeugber") and transfer specific data when an order is saved.
I used regular python libraries but it failed. (getting an error of Unable to acquire lock on context 'Ordername')
The code is very simple:

from System import *
from SoftPro.ClientModel import *
from SoftPro.OrderTracking.Client import *
from SoftPro.OrderTracking.Client.Orders import *
import requests
import json

webhook_url = 'https://hook.mine.com/o8rvt5ei' (example)

data = { 'name': 'DevOps ,
'Channel': 'Triggered from Select' }

r = requests.post(webhook_url, data=json.dumps(data), headers={'Content-type':'application/json'})

Any ideas?
Thanks for your help!
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Call a webhook from Code snippet

Post by BobRichards »

Select uses a .NET Python variant called IronPython. It does not install any of the Python import libraries when Select is installed. Instead, use .NET libraries by importing the .NET common language runtime (import clr) as in https://devforum.softprocorp.com/viewtopic.php?p=6026, https://devforum.softprocorp.com/viewtopic.php?p=5184, etc.

This behavior of communicating with external sites is beyond the original design scope of code snippets. The intended use is to manipulate orders or other Select objects. Any other use is not considered a best practice and limited, if any, help can be offered from the DevForum.
Bob Richards, Senior Software Developer, SoftPro
codvisor
Posts: 6
Joined: Wed Nov 09, 2022 12:52 pm

Re: Call a webhook from Code snippet

Post by codvisor »

Thanks!
Post Reply