Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

“Access Denied” - Magento API + C#
 
RSetubal
Jr. Member
 
Total Posts:  3
Joined:  2011-04-04
 

Hi Everybody,

I’m trying to connect my application to Magento by SOAP. My project is C# based, I created the web reference using http://www.myMagentoSite.com/api/v2_soap?wsdl=1 and I tried to connect using this code:

1 MagentoService mservice = new MagentoService();
2 String mlogin = mservice.login("APIUser", “API123456");

I always recieve a Exception with a “Access Denied” when the line #2 executes. The “APIUser” already exists with full access profile and the password is OK also. What could be wrong?

Thank’s a lot!!

Roger

 
Magento Community Magento Community
Magento Community
Magento Community
 
MageFam
Member
 
Avatar
Total Posts:  71
Joined:  2010-11-27
Minneapolis, USA
 

Hi,

Before some days ago, I got same problem .

1. Users/roles were created in admin panel correctly
2. SOAP response always said: Access Denied
3. After some time spent on class Mage_Api_Model_Mysql4_Acl, it was found that:
Method loadRules expects $rulesArr array be sorted in the way, that roles appearing in the beginning of array and users in the end.
In my case, it was not the case in table api_role

so basically, two solutions may be here:

1. Using ORDER BY parent_id = 0 DESC in SELECT from api_role table.
(which, probably, proper solution is)

2. The trick i did, just because playing with magento for the first time and don’t won’t to dig into details.
Simply resort records in api_role table.

TRUNCATE TABLE api_role; # its myisam here, so don’t care on foreign keys
INSERT INTO api_role VALUES
(8, 0, 1, 0, ‘G’, 0, ‘role1’),
(17, 0, 1, 0, ‘G’, 0, ‘role2’),
(15, 8, 1, 0, ‘U’, 2, ‘user1’),
(19, 17, 1, 0, ‘U’, 3, ‘user2’);

So as you can see, roles are on top now.
This fixed the problem.

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
RSetubal
Jr. Member
 
Total Posts:  3
Joined:  2011-04-04
 

Hi Ravi,

First of all, thanks very much for your reply. But I have a question: My APIUser doesn’t exist in my api_role. Instead this, it exists on admin_role. His group, called API, has the same role as ADMIN and, also, doesn’t exist in api_role. Do I need to INSERT it in api_role??? If I must do, I don’t know how… I mean, I don’t know what kind of data I must insert to each column in the api_role table.

Thanks in advance.

Regards,

Roger.

 
Magento Community Magento Community
Magento Community
Magento Community
 
MageFam
Member
 
Avatar
Total Posts:  71
Joined:  2010-11-27
Minneapolis, USA
 

Hi Roger,

First delete the existing api user \’s and then try again to create the api role. If that works, create the api user again and assign it to its role.

Good luck

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
RSetubal
Jr. Member
 
Total Posts:  3
Joined:  2011-04-04
 

Hi Again Ravi,

I did everything. I truncated the table and inserted, by SQL queries, all Groups (first) and Users (last) and WORKED!!! Thaks a lot!! I only needed to link again the API user to my API group and reassign the permissions to the group (everything by backend)

Thanks again,

Roger.

 
Magento Community Magento Community
Magento Community
Magento Community
 
sdsa
Jr. Member
 
Total Posts:  1
Joined:  2012-03-13
 

Hi Ravi

Thanks for the solution. It works ok from C#.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top