如何在Acumatica中发出请求或webhook?
我正在将Asp.NET应用程序与Acumatica集成,需要在Acumatica中可用时更新装运信息(跟踪、承运人等)。有没有办法让Acumatica在创建装运时调用我的Asp.NET应用程序上的端点?我已经搜索了很多文档(可用),但我并没有发现任何东西可以将信息从Acumatica发送到另一个web服务如何在Acumatica中发出请求或webhook?,acumatica,Acumatica,我正在将Asp.NET应用程序与Acumatica集成,需要在Acumatica中可用时更新装运信息(跟踪、承运人等)。有没有办法让Acumatica在创建装运时调用我的Asp.NET应用程序上的端点?我已经搜索了很多文档(可用),但我并没有发现任何东西可以将信息从Acumatica发送到另一个web服务 理想情况下,这个传出呼叫将发送有效负载中的装运对象。在我的回答中,我认为您知道如何从C#code调用一些外部服务,对于您来说,如何从Acumatica发送通知是一个挑战。 我建议您在每个Acu
理想情况下,这个传出呼叫将发送有效负载中的装运对象。在我的回答中,我认为您知道如何从C#code调用一些外部服务,对于您来说,如何从Acumatica发送通知是一个挑战。 我建议您在每个Acumatica图中扩展每个Persist方法,当对象在db中持久化时,您希望从中发送通知。IMHO最好的选择是重写persist方法(顺便说一句,T300中详细描述了重写persist方法)。在扩展类的代码中,可以执行以下操作:
public void Persist(PersistDelegate baseMethod)
{
baseMethod(); // calling this method will preserve your changes in db
//here should go your code, that will send push/pop/delete etc web request into your asp.net application. Or in other words your web hook.
}
这在您提问时不可用,但推送通知似乎正是您想要的: 帮助-
演示文稿-如果您没有Acumatica 2017R2,那么您必须创建自己的扩展项目,然后您可以从Acumatica代码调用它:
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
namespace MyApp
{
public static class Utility
{
private static WebRequest CreateRequest(string url, Dictionary headers)
{
if (Uri.IsWellFormedUriString(url, UriKind.Absolute))
{
WebRequest req = WebRequest.Create(url);
if (headers != null)
{
foreach (var header in headers)
{
if (!WebHeaderCollection.IsRestricted(header.Key))
{
req.Headers.Add(header.Key, header.Value);
}
}
}
return req;
}
else
{
throw(new ArgumentException("Invalid URL provided.", "url"));
}
}
public static string MakeRequest(string url, Dictionary headers = null)
{
WebResponse resp = CreateRequest(url, headers).GetResponse();
StreamReader reader = new StreamReader(resp.GetResponseStream());
string response = reader.ReadToEnd();
reader.Close();
resp.Close();
return response;
}
public static byte[] MakeRequestInBytes(string url, Dictionary headers = null)
{
byte[] rb = null;
WebResponse resp = CreateRequest(url, headers).GetResponse();
using (BinaryReader br = new BinaryReader(resp.GetResponseStream()))
{
rb = br.ReadBytes((int)resp.ContentLength);
br.Close();
}
resp.Close();
return rb;
}
}
}
你可以这样称呼它:
try
{
Utility.MakeRequest(theUrl, anyHeadersYouNeed);
}
catch(System.Net.WebException ex)
{
throw(new PXException("There was an error.", ex));
}
Acumatica应该立即发送消息吗?@Yurazaletsky,是的,那将是理想的。几乎就像一个webhook,在一个航运信息更新事件中触发。Acumatica中的PushNotifications功能正在开发中,我们希望它很快就会发布。你知道我在哪里可以找到关于如何修改Acumatica图表的课程文档吗?另外,我是否可以获取要与web请求一起发送的持久化对象?您在问题中已经提到了链接。我建议您先看T100课程的前几章,然后在pdf格式的T300课程中,您将看到如何扩展类库。在以下链接中,您可以看到更多详细信息:。如果你觉得我的帖子很有用,请记下我的答案,因为plzI没有机会完全测试这一点,但你的博客帖子很有用。非常感谢。