In the CRT in the commerceSDK, I have a controller class called ProcessHQFormControllerTMC.
[HttpPost]
[Authorization(CommerceRoles.Application, CommerceRoles.Customer, CommerceRoles.Employee)]
public async Task<string> TMCProcessSalesHubHQForms(IEndpointContext context, string paramData)
{
HQFormFromSalesHubRequestTMC request = new HQFormFromSalesHubRequestTMC(paramData);
HQFormFromSalesHubResponseTMC response = await context.ExecuteAsync<HQFormFromSalesHubResponseTMC>(request).ConfigureAwait(false);
return response.errorMsg;
}
In the end I will have to call this from Power Automate.
The business case is to add an action control button on SalesHub grid which will call the Power automate flow which will call the CRT code.
However I am trying to test it in Postman, but I can't get it to work.
Please note, I am testing this inside my Development environment which is an RDP ( cloud-hosted environment)..
I used the below 2 documents to do the setup for the AAD token.
The documentation isn't clear about the User ID I should use when adding the entry in the Microsoft EntraID application, so I used RetailServerAccount, similar to what I use for the retail server and async client entra IDs for the IIS-Hosted scale unit on my Dev box.
Retrieving the token itself works in Postman.
Also, adding the POST request for adding a customer in HQ using the standard API Customers/CreateCustomer which is in the documents links above as an example, work as well. The record is created successfully in HQ.
IT added for me the following permissions in Azure Portal for the app registration they added that I'm using in the identity providers and Entra ID setup in HQ:
As I said, calling the standard CommerceSDK API to create a customer in HQ via Postman, works correctly.
Which means the AAD setup and the setup inside HQ on the identity provider and Application entra ID, is correct.
However I cannot get it to work with my custom API.
As you can see from the above code snippet, it wants the IEndpointcontext and the paramData as arguments.
I don't know where it gets the IEndpointContext from, I can only assume it is generated with the parameter oun-header entry which have the value of the operating unit number of the retail store I'm using.
My parameters for Header:
The setup in the body section:
If I add the request POSt as follow, then I get a 404-error that it can't find it:
{{General_RetailServer}}/Commerce/ProcessHQFormControllerTMC/TMCProcessSalesHubHQForms?api-version=7.3
If I replace ProcessHQFormControllerTMC with StoreOperations, becasue the latter is how POS finds it, then I also get the 404-error.
If I call it only as:
{{General_RetailServer}}/Commerce/TMCProcessSalesHubHQForms?api-version=7.3
Then I get the error.
Can somebody please tell me what I'm doing wrong.
Is the AAD token app permissions incorrect that it can't see the custom, only the standard API's?
However the 500 error looks to me like it can't talk to the retail server as if its down.