acumatica 23r2 中的 WebHook 问题。 Acumatica 23 R1 工作正常

问题描述 投票:0回答:1

我在 Acumatica 中使用 Webhooks 发送客户批准通知、接受响应并在 Acumatica 中更新它们。

Webhook 链接通过电子邮件通知发送到 Acumatica。通过单击该链接,它会显示自定义页面以供客户批准。该例程在 Acumatica 23 R1 中运行良好,但在编译下面给出的代码时抛出错误。

    using PX.Data;
using PX.Data.Webhooks;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web;
using PX.Api.Webhooks.DAC;
using PX.Objects.SO;
using PX.SM;
using PX.Objects.CS;
using PX.Api.Services;
using INFOLicence;
namespace CustomWebhook
{
    public class ArtApprovalJobWebHooksServerHandler : IWebhookHandler
    {
        private NameValueCollection _queryParameters;

        private const string cLocationCD = "KeyValues";
        private const string cMode = "Mode";
        private const string cSendMode = "SendNotification";
        private const string cGetMode = "ReceiveResponse";

        async Task<IHttpActionResult> IWebhookHandler.ProcessRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            using (var scope = GetUserScope())
            {
                _queryParameters = HttpUtility.ParseQueryString(request.RequestUri.Query);

                string htmlResponse = string.Empty;
                if (!_queryParameters.AllKeys.Contains(cLocationCD))
                    throw new Exception($"The {cLocationCD} Parameter was not specified in the Query String");
                var collectorID = _queryParameters[cLocationCD];
                try
                {
                    string sMode = string.Empty;
                    string values = collectorID;//Password.Decrypt(collectorID);
                    string[] arr = values.Split(new char[] { ';' });
                    string ordertype = arr[1];
                    string ordernbr = arr[2];
                    string locationcd = arr[4];
                    string setuptype = arr[0];
                    string jobcode = arr[3];
                    if (!_queryParameters.AllKeys.Contains(cMode))
                    {
                        //if nothing is specified for a mode Parameter we will assume GetSurvey
                        sMode = "SendNotification";
                    }
                    else
                    {
                        sMode = _queryParameters[cMode];
                    }

                    switch (sMode)
                    {
                        case cSendMode:
                            htmlResponse = GetSendAuth(cLocationCD, ordertype, ordernbr, locationcd, setuptype,jobcode); // invoking page from customer side for approval
                            break;
                        case cGetMode:
                            htmlResponse = SubmitApproval(collectorID, request); // Updating customer response
                            break;
                        default:
                            //htmlResponse = ReturnModeNotRecognized(sMode);
                            break;
                    }
                }
                catch (PXException e)
                {
                    throw e;
                }
                return new HtmlActionResult(htmlResponse);
            }
        }
    }
}

我无法弄清楚这个问题。请让我知道如何解决这个问题

更新

我正在生成以下 URL 以发送给客户

http://localhost/PrintShop23R2/Webhooks/Company/7fc9c9e3-05c9-4514-93d3-50a4beae9dcc?KeyValues=S;SO;SO007463;000001005;Location%201&Mode=SendNotification

以下 URL 抛出以下错误

{
    "title": "An error has occurred.",
    "status": 500,
    "traceId": "80166d95-91d6-47fb-9b5a-b9224934962e"
}
acumatica
1个回答
0
投票

Webhook 在 23R2 中从

PX.Data.Webhooks
移至
PX.Api.Webhooks

此外,处理程序也发生了更改:

    public async Task HandleAsync(WebhookContext context, CancellationToken cancellation)
    {
        if (context.Request.Method == HttpMethod.Post.Method) 
        {
            //
        }
    } 
© www.soinside.com 2019 - 2024. All rights reserved.