Discussion:
The request failed with HTTP status 401: Unauthorized.
(too old to reply)
Liift
2009-08-03 23:37:02 UTC
Permalink
Hi I am geting Unauthorized error in my code

public static string GeocodePoint(string streetaddress)
{
MapPointService.FindServiceSoap findService = new
MapPointService.FindServiceSoap();
string latlong = "Unavailable";

//findService.Credentials =
System.Net.CredentialCache.DefaultCredentials;
findService.Credentials = new
System.Net.NetworkCredential("panchalUjwal144176", "up1977");
findService.PreAuthenticate = true;


//Define the address specification for MWS
MapPointService.Address myAddress = new MapPointService.Address();
myAddress.FormattedAddress = streetaddress;

//Set the search options
MapPointService.FindOptions myFindOptions = new
MapPointService.FindOptions();

MapPointService.FindAddressSpecification findAddresSpec = new
MapPointService.FindAddressSpecification();
findAddresSpec.InputAddress = myAddress;
findAddresSpec.Options = myFindOptions;
//findAddresSpec.DataSourceName = "panchalUjwal144176.144176";
findAddresSpec.DataSourceName = "MapPoint.World";

//Set the ResultMask to include the rooftop geocoding values
findAddresSpec.Options.ResultMask =
MapPointService.FindResultMask.RooftopFlag |
MapPointService.FindResultMask.LatLongFlag |
MapPointService.FindResultMask.EntityFlag |
MapPointService.FindResultMask.MatchDetailsFlag |
MapPointService.FindResultMask.AddressFlag;
//Call the MWS FindAddress method
MapPointService.FindResults myFindResults =
findService.FindAddress(findAddresSpec); /* error on this line */

//Parse the Results
MapPointService.FindResult bestResult = myFindResults.Results[0];
int matchcode = 0;

MapPointService.EntityPropertyValue[] props =
bestResult.BestViewableLocation.Entity.Properties;

//Find MatchedMethod property which tells you whether rooftop
was used
for (int i = 0; i < props.Length; i++)
{
if (props[i].Name == "MatchedMethod")
{
matchcode = System.Convert.ToInt32(props[i].Value);
}
}
//Prepare result
if (matchcode == 7)
{
latlong = "new VELatLong(" +
bestResult.BestViewableLocation.LatLong.Latitude
+ ", " + bestResult.BestViewableLocation.LatLong.Longitude + ")";

}




return latlong;

}


I check my account in Bling Maps Enterpise for Account .They say my Account
is set up properly. So Can you please tell me where I am going wrong.
Derek Chan
2009-08-06 15:50:11 UTC
Permalink
Hi,

I'm getting 401 Unauthorized too using your credentials, can you verify that
the credentials in your code is correct? I used a simple app below and got
the error using the MWS Staging environment:

FindServiceSoap findService = new FindServiceSoap();
findService.Credentials =
new System.Net.NetworkCredential("panchalUjwal144176",
"up1977");

FindByIDSpecification findbyidspec = new FindByIDSpecification();
findbyidspec.DataSourceName = "MapPoint.FourthCoffeeSample";
findbyidspec.Filter = new FindFilter();
findbyidspec.Filter.EntityTypeName = "FourthCoffeeShops";
int[] arrayID = { -21835, -21836 };
findbyidspec.EntityIDs = arrayID;

FindResults foundResults;
foundResults = findService.FindByID(findbyidspec);

Regards,
--
Infusion Development
http://www.infusion.com
Post by Liift
Hi I am geting Unauthorized error in my code
public static string GeocodePoint(string streetaddress)
{
MapPointService.FindServiceSoap findService = new
MapPointService.FindServiceSoap();
string latlong = "Unavailable";
//findService.Credentials =
System.Net.CredentialCache.DefaultCredentials;
findService.Credentials = new
System.Net.NetworkCredential("panchalUjwal144176", "up1977");
findService.PreAuthenticate = true;
//Define the address specification for MWS
MapPointService.Address myAddress = new MapPointService.Address();
myAddress.FormattedAddress = streetaddress;
//Set the search options
MapPointService.FindOptions myFindOptions = new
MapPointService.FindOptions();
MapPointService.FindAddressSpecification findAddresSpec = new
MapPointService.FindAddressSpecification();
findAddresSpec.InputAddress = myAddress;
findAddresSpec.Options = myFindOptions;
//findAddresSpec.DataSourceName = "panchalUjwal144176.144176";
findAddresSpec.DataSourceName = "MapPoint.World";
//Set the ResultMask to include the rooftop geocoding values
findAddresSpec.Options.ResultMask =
MapPointService.FindResultMask.RooftopFlag |
MapPointService.FindResultMask.LatLongFlag |
MapPointService.FindResultMask.EntityFlag |
MapPointService.FindResultMask.MatchDetailsFlag |
MapPointService.FindResultMask.AddressFlag;
//Call the MWS FindAddress method
MapPointService.FindResults myFindResults =
findService.FindAddress(findAddresSpec); /* error on this line */
//Parse the Results
MapPointService.FindResult bestResult = myFindResults.Results[0];
int matchcode = 0;
MapPointService.EntityPropertyValue[] props =
bestResult.BestViewableLocation.Entity.Properties;
//Find MatchedMethod property which tells you whether rooftop
was used
for (int i = 0; i < props.Length; i++)
{
if (props[i].Name == "MatchedMethod")
{
matchcode = System.Convert.ToInt32(props[i].Value);
}
}
//Prepare result
if (matchcode == 7)
{
latlong = "new VELatLong(" +
bestResult.BestViewableLocation.LatLong.Latitude
+ ", " + bestResult.BestViewableLocation.LatLong.Longitude + ")";
}
return latlong;
}
I check my account in Bling Maps Enterpise for Account .They say my Account
is set up properly. So Can you please tell me where I am going wrong.
Loading...