<?xml version="1.0" encoding="windows-1252"?>
<node id="997077" title="Re: Bing API Authentication in Perl" created="2012-10-03 11:37:07" updated="2012-10-03 11:37:07">
<type id="11">
note</type>
<author id="155876">
Mr. Muskrat</author>
<data>
<field name="doctext">
&lt;p&gt;If you are going to use the four argument credentials, you need to pass the right data into it. Location is &lt;host&gt;:&lt;port&gt; as documented in [mod://LWP::UserAgent].&lt;/p&gt;

&lt;p&gt;Try this totally untested piece of code and see if you get better results.&lt;/p&gt;

&lt;code&gt;
#!/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;
use Crypt::SSLeay;

my $mech = WWW::Mechanize-&gt;new();

# Don't pass the full URL as the location in the call to credentials!
my $server = 'api.datamarket.azure.com'; 
my $url  = "https://$server/Bing/SearchWeb/Web?Query=%27Xbox%27&amp;$top=10&amp;$format=JSON";
my $loc = "$server:443"; 
my $account_key = "&lt;my key&gt;";

# Yes, WWW::Mech still supports LWP::UserAgent's four arg credentials
$mech-&gt;credentials($loc, '', '', $account_key);

$mech-&gt;get($url);

print $mech-&gt;content();
&lt;/code&gt;
&lt;p&gt;Update: After I posted this, I realized that you were using https so I updated the port from 80 to 443.&lt;/p&gt;</field>
<field name="root_node">
996948</field>
<field name="parent_node">
996948</field>
</data>
</node>
