Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Insufficient authorization to perform this action - GP web services from ASP.Net

(0) ShareShare
ReportReport
Posted on by

I'm trying to create an ASP.Net web service that will call the GP web services but when calling the CreateReceivablesInvoice service it is failing with the error "Insufficient authorization to perform this action"

I am connecting to the service as a user that is setup in the Dynamics Security Console as a superuser and have proved that all works correctly when calling the CreateReceivablesInvoice service from a standard Windows Forms app. The same code, however, doesn't work from the ASP.Net web app.

The code is as follows and it fails on the last line:

CompanyKey companyKey;
Context context;
ReceivablesDocumentKey invoiceKey;
CustomerKey customerKey;
MoneyAmount invoiceAmount;
ReceivablesInvoice receivablesInvoice;
Policy receivablesInvoiceCreatePolicy;

// Create an instance of the service
GPService.DynamicsGPClient wsDynamicsGP = new GPService.DynamicsGPClient();

wsDynamicsGP.ClientCredentials.UserName.UserName = "domain\\username";
wsDynamicsGP.ClientCredentials.UserName.Password = "password";

// Create a context with which to call the service
context = new Context();

// Specify which company to use (sample company)
companyKey = new CompanyKey();
companyKey.Id = (1);

// Set up the context object
context.OrganizationKey = (OrganizationKey)companyKey;

// Create the document key to uniquely identify the receivables invoice
invoiceKey = new ReceivablesDocumentKey();
invoiceKey.Id = invoice.InvoiceNumber;

// Create a customer key object to specify the customer
customerKey = new CustomerKey();
customerKey.Id = invoice.CustomerNumber;

// Create a money amount object to specify the invoice amount
invoiceAmount = new MoneyAmount();
invoiceAmount.Currency = "STG";
invoiceAmount.Value = Convert.ToDecimal(invoice.InvoiceValue);

// Create the receivables invoice object
receivablesInvoice = new ReceivablesInvoice();

// Populate the receivables invoice object's required properties
receivablesInvoice.Key = invoiceKey;
receivablesInvoice.CustomerKey = customerKey;
receivablesInvoice.SalesAmount = invoiceAmount;

// Get the create policy for receivables invoices
receivablesInvoiceCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateReceivablesInvoice", context);

// Create the receivables invoice
wsDynamicsGP.CreateReceivablesInvoice(receivablesInvoice, context, receivablesInvoiceCreatePolicy);


I've seen the following post: https://community.dynamics.com/gp/b/dynamicsthoughts/archive/2014/08/08/how-to-solve-the-error-insufficient-authorization-to-perform-this-action-in-web-services-for-microsoft-dynamics-gp

but I don't see GPWebServicesAppPool in the list of application pools in IIS and I also can't find the web.config file referred to in that post.

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Insufficient authorization to perform this action - GP web services from ASP.Net

    Please ignore this question. When testing this I had the customer number set incorrectly to a non-existent customer which I think explains the error. After correcting that, the code above does actually work, which is nice.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,095 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans