-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solving Magento Enterprise edition/.NET integration rest #11
Comments
it's asynchronous so you need a handler for the event in the drop down. declare the client withevents at the too of your class then look for the On Jan 31, 2014, at 12:14 AM, 78fede78 notifications@github.com wrote: I'm trying to make a request HTTP from .NET to Magento 1.8 Enterprise OAuth Authentication is working and reply also correct token Dou you have any suggestion to resolve this problem? Any idea why I don't receive a response? Here following the code I'm using: var client = new MagentoApi().Initialize("http://test.xxxxxxxxx.nl", I tried to debug your code but it stops here: var response = await Client.ExecuteTaskAsync(request); Can you please help me out? Reply to this email directly or view it on |
// in an async method var response = await client.GetProductBySku("123456"); |
Note that this library has not been tested yet against Magento 1.8 response = client.GetProductBySku("123456").Result; |
unfortunately yes, the result does not change. Does not work.... We are on Magento Enterprise 1.13 - might there be an issue there? |
CallbackUrl is not important? InitializeRestClient(); |
Not in this implementation because we are user and server in 1 implementation (which actually is contradictory to what openauth is trying to accomplish). In step 5 from https://github.com/nickvane/Magento-RestApi/wiki/Authentication-steps To respond to your issue: I have no access to an enterprise edition so can't test this for you. You could however try to debug the requests with http://fiddler2.com/ and see what the server is returning as response. |
I have done debugging my application with fiddler. It was just a matter of reading. How do I know that the request has been completed? Where am I doing wrong?
|
I also made a small change to the source code.
MagentoApi.cs Line 338 Instead of:
I corrected
|
Yes, I already had this one as local change, but haven't pushed yet.
|
In console application works perfectly:
you can get the same result in web application? |
I am having the same problem. It doesn't give an error, it just freezes. It works in a console application but not in a winform application. Fiddler returns the correct result. I have tried Magento community 1.7 and 1.8. |
Hi, your Magento REST API client looks interesting and I thought I would test it out. I see this thread is similar to what I am trying and I don't know if I have the same problem as other people here. I created an ASP.NET Razor project and tried calling this from a webpage: var client = new MagentoApi().Initialize("http://localhost:8080", "key", "secret").AuthenticateAdmin("user", "password"); In Web Services -> REST Roles, I created a new Admin role and assigned a user to this role. I passed this user and password into AuthenticateAdmin above. My Magento website is running locally at localhost:8080 on a PC using WAMPSERVER When I run the code I get this error: The remote server returned an error: (404) Not Found. Any ideas what I'm doing wrong? Thanks!!! |
I changed the URL parameter from "http://localhost:8080" to "http://localhost:8080/index.php" and now it gets past the previous error. Now I get this error: Additional information: The provided consumer secret was rejected by the server at url 'http://localhost:8080/index.php/oauth/initiate' for consumer key 'xxxxxxxxxxxxxxxx'. |
Just to follow up, the oAuth Magento code was stripping out my port number so I made a temporary change to the code and now I get past the error above. Now I have the exact error as the original poster, my code just hangs on this line: var response = await Client.ExecuteTaskAsync(request); If anyone has any solution, I would love to hear. Thanks! |
Hey primico, But I think I'll have to explore going this direction again. So thanks for all the comments, they are helpful, especially knowing it wasn't just me with the issue. Dylan |
In the Magento code: Let me know if you get everything working. My code won't get past ExecuteTaskAsync. I tried to see if I can use ExecuteAsync instead, but I get a different error. Oh well... |
Alright, I made those changes and they worked perfectly. After that getting past authentication works fine (no more errors). But now I'm stuck exactly where you are. I did find that atleast in my installation that the .htaccess was missing a line: RewriteRule ^api/rest api.php?type=rest [QSA,L] Now if I go to: http://localhost:8080/api/rest/products within a browser and I turn on full access for Guests, I see an XML response. But it still won't work and hangs at that exact line. Very frustrating, but I'll spend maybe a few more hours with it this weekend, hopefully we figure this out! |
Hey, Okay seems to be working if we call the different API calls using Async. I did find one more issue in the source (MagentoApi.cs) at line 337: Change: if (response.ContentType.ToUpperInvariant() = "APPLICATION/JSON") To: if (response.ContentType.ToUpperInvariant().Contains("APPLICATION/JSON")) Basically my code was adding additional values to the ContentType, so using a contains will still match if that's the case. Seems the rest is now working correctly now! |
I think I may have to take a look at that async code to make it work synchronously. |
Hey, I should clarify, this wasn't an enterprise issue, atleast for me, it had the problem in the community edition. I think the big issue with it, was that we were both using our local wamp server, and just so happen to both be using a different port than the standard 80. I can assume that's because we both had IIS running on 80. Since I'm just about done with the project, I have two suggestions, and wasn't sure of where to put them.
~ Dylan |
Huge thanks to Nick and Micah for sharing their code with the community... Had this exact problem with Enterprise v1.12.0.0 trying to call methods from an asp.net webform. I imagine this also applies to Magento community. As mentioned in the posts above, I updated line 339 inside MagentoApi.cs to... if (response.ContentType.ToUpperInvariant().Contains("APPLICATION/JSON")) But the code below (line 337 inside MagentoApi.cs) would still hang no matter what I tried... After some trial and error I found you need to change the way you call the API methods if you're calling them from a web form or any web UI for that matter. This will work fine (does not hang) from a console app or unit test... var response = client.GetProductBySku("123456").Result; .. but doesn't work from an aspx page. What you need to do is stick the API call in a new aync task and then register it with the page....e.g. from a button click or Page_Load... e.g. protected void btnFindProd_Click(object sender, EventArgs e) private async Task GetProductInfo() For this to work, you need to add Async="true" to the page directive Some good reading here: Hope that saves someone a few hours :) |
Hi, a have a problem I need, get to cateries description whit API REST please Help I used Magento 1.9 |
I'm trying to make a request HTTP from .NET to Magento 1.8 Enterprise edition,
but apparently I don't have any response.
OAuth Authentication is working and reply also correct token
Dou you have any suggestion to resolve this problem?
Any idea why I don't receive a response?
Here following the code I'm using:
Can you please help me out?
Thank you
Regards
The text was updated successfully, but these errors were encountered: