Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Processing incoming request from Outside world
using Newtonsoft.Json;
using PX.Data;
using PX.Data.Webhooks;
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http.Results;
namespace WebHooksConfiguration
{
class ObjectJSON
{
string Name { get; set; }
}
public class TestWebHooks : IWebhookHandler
{
public async Task<System.Web.Http.IHttpActionResult> ProcessRequestAsync(
HttpRequestMessage request, CancellationToken cancellationToken)
{
using (var scope = GetAdminScope())
{
if (request.Method == HttpMethod.Post)
{
string jsonContent = request.Content.ReadAsStringAsync().Result;
ObjectJSON obj = JsonConvert.DeserializeObject<ObjectJSON>(jsonContent);
}
}
return new OkResult(request);
}
private IDisposable GetAdminScope()
{
var userName = "admin";
if (PXDatabase.Companies.Length > 0)
{
var company = PXAccess.GetCompanyName();
if (string.IsNullOrEmpty(company))
{
company = PXDatabase.Companies[0];
}
userName = userName + "@" + company;
}
return new PXLoginScope(userName);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment