scolife has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks. I have really terrible error. I consuming web service which gives me xml; # service will give me information relating to student ID
<to_user_info> <photo>https://webdomainasdad/getstapic.ashx?id=10010008460</photo +> <lastname>asssa</lastname> <firstname>asdadas</firstname> <sisiid>06B06B10253</sisiid> <school>asdasd</school> <program>asdasas</program> <registerNr>asd89021800</registerNr> <phones/> <emails/> <userStatus> res</userStatus> <usertype>1</usertype> </to_user_info>
If I call web service which shows image "https://webdomainasdad/getstapic.ashx?id=10010008460" It returns correct Image and I can save it to MYSQL
But if I call this service like
(Because I must add pictures of Students to sub system and Pictures has given in URI in XML)
$photo = "https://webdomainasdad/getstapic.ashx?id=1001000846 +0"; #$photo is parsed from XML my $res = $ua->get("$photo"); my $imgfile = $res->content;

This Web service does not give me photo. How can I fix this. Please I am really confused.

Replies are listed 'Best First'.
Re: Web service called with wrong parameter
by Corion (Patriarch) on Sep 14, 2015 at 11:59 UTC

    Maybe you need cookies? Maybe the data is only available through the web service and not through naked HTTP?

    The best approach is to compare the network traffic that your working client sends with the network traffic that your Perl script sends and eliminate everything that is different until it works.

Re: Web service called with wrong parameter
by choroba (Cardinal) on Sep 14, 2015 at 11:55 UTC
    Your description of the problem is incomplete. How do you parse the XML? How is the successful call of the service different to the unsuccessful one? Do you mean it works in a browser, but not in the code?
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Yeah its works in browser. But does not work in code. And If I call this service in code as a below
      my $res = $ua->get("https://webdomainasdad/getstapic.ashx?id= +10010008460"); my $imgfile = $res->content;
      It gives me image.
Re: Web service called with wrong parameter
by castaway (Parson) on Sep 14, 2015 at 12:21 UTC

    I assume you've tested that $photo is what you expect it to be?

    What do you get in $imgfile? Have you looked at $res->is_success or $res->code? (just dumping the whole $res object is a useful debugging aid).

    My guess would be that you need to tell the backend what types of image files you will take, eg $ua->default_header('Accept' => 'image/jpeg')

    As Corion says. open the debugger in your browser, and look to see which headers the browser sends/gets when you ask it to get that image URL