Hello Eran, On 08/20/2014 02:30 PM, eran meiri wrote:
I need to access Citrix Odata api and for some reason I can't. when I try to access the URL with my browser I get a prompt to the domain\user an password. when I enter them I get the data I need but it doesn't work with the Perl script.
I'm not familiar with OData nor citrix, but I can suggest few things to try. I don't know what you're already tried, so some might be obvious; Others might be an over-kill.
all of these options give me the same result : 401 unauthorized the domain , user and password are all correct since I can access the URL from the browser. H E L P
First, From a brief glance, it look like "Odata" is a Microsoft invention, which puts the whole "Open" in question... :) You might want to look at existing libraries, and use a library that works (though I can't see a Perl one): http://www.odata.org/libraries/ http://en.wikipedia.org/wiki/Open_Data_Protocol#Client_libraries Second, I would try to login to your Citrix server from multiple browsers, first with Javascript enabled and then disabled. If it works from all browsers with Javascript disabled, it hints that it "should be" standard HTTP (with XML/SOAP/whatever on top of it) - which is good for you. If it requires Javascript or only works on specific browsers, then it might indicate some tricks are needed. Third, I'd try something like "Firefox Live Headers" extension: https://addons.mozilla.org/en-us/firefox/addon/live-http-headers/ An extension that will show you the HTTP headers being sent and received. This will allow you to compare the information the browser sends vs. what your Perl script sends. There could be a critical step/cgi-parameter/cooke part missing in your Perl part. Fourth, If it's really just HTTP protocol, even with XML/SOAP on top, and assuming the password is sent as-is (which is strange, but I can't tell from your example), then you should be able to re-produce this using "cURL" (the command-line HTTP program). "cURL" is vary capable when it comes to emulating requests, including FORMS and CGI-Parameters and HTTP input data. Especially if you can record the HTTP headers from the browser, see if you can reproduce them with cURL. Fifth, Pulling out the big guns, you can always resort to Wireshark/Ethereal to see that is the differences between what the browser sends and what your Perl script sends (assuming again, that it's HTTP and not HTTPS; although that can be resolved too, if needed). Do this to capture the HTTP communication: 1. close the browser. 2. run this command (replacing 1.2.3.4 with your citrix host name): sudo tshark -i any -f 'host 1.2.3.4 and tcp port 80' -s 65000 -w - > browser.cap (Keeo this running) 3. Open your browser, go to your citrix server page, login as usual. 4. close the browser. 5. Kill "tshark" with CTRL+C. 6. run 'tshark' again, saving too a different file: sudo tshark -i any -f 'host 1.2.3.4 and tcp port 80' -s 65000 -w - > perl.cap (Keeo this running) 7. in a new terminal window, run your perl script, until it fails. 8. Kill "tshark" with CTRL+C. 9. run the following commands: wireshark -d http browser.cap & wireshark -d http perl.cap & This will open Wireshark and display the HTTP packets from both of your capture. Each line *should* be an HTTP message (sent or received), and you should be able to spot the differences. Using 'wireshark' is not trivial, but is worth the trouble of learning to use it. If you don't spot any obvious difference bet still see failures, perhaps it means there is communication to another server (which the 'tshark' command ignored', or communication over another port (not HTTP/80), which 'tshark' also ignored. --- Of course, all of the above isn't needed if you can simply get help/support from Microsoft or Citrix.... Good luck, - Assaf _______________________________________________ Perl mailing list [email protected] http://mail.perl.org.il/mailman/listinfo/perl
