I want to create a customer in Dynamics GP through GP WebServices and I wrote some code but throwing an exception as Insufficient Authorization to perform this Action.My code is here
try
{
CompanyKey companyKey;
Context context;
Customer customer;
CustomerKey customerKey;
Policy customerPolicy;
// Create an instance of the service
DynamicsGPClient wsDynamicsGP = new DynamicsGPClient();
// 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
context.OrganizationKey = (OrganizationKey)companyKey;
// Create a new customer object
customer = new Customer();
// Create a customer key
customerKey = new CustomerKey();
customerKey.Id = "CONTOSO";
customer.Key = customerKey;
// Set properties for the new customer
customer.Name = "Contoso,Ltd";
// Get the create policy for the customer
customerPolicy = wsDynamicsGP.GetPolicyByOperation("CreateCustomer", context);
// Create the customer
wsDynamicsGP.CreateCustomer(customer, context, customerPolicy);
// Close the service
if (wsDynamicsGP.State != CommunicationState.Faulted)
{
wsDynamicsGP.Close();
}
}
catch(Exception ex)
{
throw ex;
}
*This post is locked for comments