Calling Mingle REST API with WinForms#578
|
|
I’ve been building in a web app without issue accessing the Mingle REST API. Now I’m trying to get it to work in a WinForms app (C#) and not getting any success. I’ve tried the following combinations, none of which work and all return me an unauthorized error: WebClient client = new WebClient(); WebClient client = new WebClient(); WebClient client = new WebClient(); WebClient client = new WebClient(); Like I said, nothing is working. They all return a 401 error (Unauthorized) but the username I’m specifying is me (an admin) and I’m running the application under my credentials. I’ve tried adding “basic_auth_enabled: true” to the auth_config.yml file but that doesn’t help either. Anyone have a suggested combination that works? |
|
|
For making sure the Mingle server enabled basic auth, you can simply type the uri into browser to test it. For example, you can type ‘http://[user]:[password]@[server]:[port]/projects/[project]/cards.xml’ in your browser to see whether there is xml responded. For WinForms app, please check how WebClinet works with HTTP Basic Auth. WebClient client = new WebClient(); Here is original post where I got the code: http://www.eggheadcafe.com/tutorials/aspnet/c841f26a-bcff-453f-8305-3c644cac25a9/webclient-class-gotchas.aspx I don’t get an environment to try it, hope it can help you. |
|
|
I have basic_auth_enabled: true in my config file, but I’m looking up users via LDAP so that’s configured as well (and working). If I try the http://[user]:[password]@[server]:[port] in my browser (after signing out of Mingle) I just get a blank page (I’m assumine a 401 or 500 error) CredentialCache.DefaultCredentials just grabs the credentials from the current user signed into the OS and uses it. The syntax you listed doesn’t work and results in a 401 (unauthorized) error. For the life of me, I cannot figure out how to do this with a LDAP integrated setup (Mingle users/passwords works fine) and it’s highly frustrating. |
|
|
One more thing, if I sign out of Mingle and enter this into the browser: http://[server]:[port]/projects/[project]/cards.xml Using fiddler I see this header come back (using IE6): HTTP/1.1 401 Unauthorized Incorrect username or password. |
|
|
Hi Bil, Since you said: “If I try the http://[user]:[password]@[server]:[port] in my browser (after signing out of Mingle) I just get a blank page (I’m assumine a 401 or 500 error)” Please type in a correct rest api url, e.g. http://[user]:[password]@[server]:[port]/projects/[project]/cards.xml The following config content works for me(I just put the ‘basic_auth_enabled’ at the end of the config: |
|
|
the url “http://[server]:[port]/projects/[project]/cards.xml” you typed in the browser can’t be authorized since you didn’t provide the user name and password. In the browser, for using the http basic auth, you should always provide user and password between ‘http://’ and ‘[server]’, e.g. http://user:password@[server]:[port].... So the response is correct. |
|
|
@LiXiao: Sorry, I did mean to use the full URL in the original message, just figured I didn’t have to spell everything out. I’m giving up on trying to get LDAP and the REST API to work as I just can’t get it to work. I’ve got the configuration you mentioned and restarted the server. I’ve entered this in my browser (IE6): Where [username] is my username (I’ve signed out of Mingle previously and opened a new browser session). This is my username without the domain prefix, same as what I sign into the Mingle login page with. I can’t tell what error is coming back. I get a title bar of “Invalid syntax error” and some text on the page that says “The page cannot be displayed” and “The page you are looking for might have been removed or had its name changed” At this point I’m only going to provide support for my plugin for non-LDAP setups until someone can get me information that works in my test setup. Problem is there’s no information Mingle is providing me to help diagnose the problem. Thanks. |
|
|
More information. Turns out that I’m using IE6 and they’ve disabled the username:password@server syntax with a security patch some time ago. Unfortunately I don’t have access to anything but IE6 for testing right now (so FF or something is a problem). I did find a registry hack to remove this behavior and just trying to get the link working in the browser first. I still think there’s something wrong in the Mingle API to get this working. For example, I’m trying to run against my own local install (localhost) on port 8080 with non-LDAP authentication (Mingle is keeping track of usernames and passwords). Here’s the request when I use the username:password@server:port syntax in my browser: GET /projects/test/cards.xml HTTP/1.1 And here’s the response: Incorrect username or password. I know I’m using the correct username/password here (typed it into the login form). Is it possible Mingle cannot handle the username:password url *and a specified port number? Or maybe this just won’t work in IE6 no matter what? |
