Windows Azure: Error 300 Ambiguous Redirect when creating a blob container - windows

I followed a tutorial on creating a blob on windows azure. But when I do that, I get an exception error:
Error while creating containerThe server encountered an unknown failure: The remote server returned an error: (300) Ambiguous Redirect.
The code is:
private void SetContainersAndPermission()
{
try
{
// create a container
var CloudAccountStorage = CloudStorageAccount.FromConfigurationSetting("BlobConnectionString");
cloudBlobClient = CloudAccountStorage.CreateCloudBlobClient();
CloudBlobContainer blobContainer = cloudBlobClient.GetContainerReference("documents");
blobContainer.CreateIfNotExist();
// permissions
var containerPermissions = blobContainer.GetPermissions();
containerPermissions.PublicAccess = BlobContainerPublicAccessType.Container;
blobContainer.SetPermissions(containerPermissions);
}
catch(Exception ex)
{
throw new Exception("Error while creating container" + ex.Message);
}
}
Can anyone tell me How to solve this problem....

I would guess the connection string is somehow wrong? Can you share the connection string? (X out your shared key...)
You could also install Fiddler (debugging HTTP proxy) and see what the HTTP request looks like. That may make the issue more obvious.

I also faced the same issue. I am not sure if this is the workaround for it. I modified the container name value in ServiceConfiguration.csfg from "Photograph" to "photograph" and it worked.

I think you can not give upper case letters in queue, table or blob name. The name should have only lower case characters.

Related

Google Translate API - Error code 400

So I'm getting an error code 400 with a keyInvalid reason:
json = {
error = {
code = 400;
errors = (
{
domain = usageLimits;
message = "Bad Request";
reason = keyInvalid;
}
);
message = "Bad Request";
};
}
I'm using the correct API call I'm sure:
https://www.googleapis.com/language/translate/v2?key=INSERT-YOUR-KEY&q=hello%20world&source=en&target=de
And for INSERT-YOUR-KEY I've tried both the Client ID and the Client secret.
Also, I do have the Translate API turned on in the console.
Oh lord, what a waste of time - mostly my fault! So I needed to create a public API key, which was the second option on the page staring right in the face this whole time. One of those days...

quickbooks online sdk v3 how to troubleshot a badrequest/ValidationException

When debugging a program using the QuickBooks Online API V3 with the SDK. How do you troubleshoot a bad request coming from DataServices. I have gone through several layers of the Exception innerExceptions and I only see ValidationException.
But what tripped the validation exception???
Is there a log to see what caused the problem?
catch (Intuit.Ipp.Exception.IdsException ex)
{
//TODO: handle dupe or other....
var returnMessage = string.Empty;
var innerException = ((Intuit.Ipp.Exception.ValidationException)(ex.InnerException)).InnerExceptions.FirstOrDefault();
if (innerException != null)
{
returnMessage = innerException.Message;
}
}
I just found out this when looking deeply into the exception generated.
Generally speaking you will get an exception and you check if the inner exception object is not null or nothing, if it has an inner exception you look at it.
You will notice that every exception also has a property called "InnerExceptions" (plural) which is a list containing inner exceptions, this property will be null when you have a proper inner exception, but in the last one (in my case) when the inner exception property is null this list contains one inner exception with the details.
This property is available on Intuit.Ipp.Exception.IdsException and contain a list of IdsError
I'm using the IPP .Net SDK 3.0 API (version 2.0.2.0)
For .Net SDK please enable request/response logs. Th details for bad exception get saved in these files.
https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0150_ipp_.net_devkit_3.0/logging
Please mention which SDK(JAVA/.NET/PHP) you are using.
https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits
You can set the logger to debug mode to capture the raw request and response XMLs. From the response XML, you'll get the details of failure(if any).
Otherwise, you can call these endpoints directly from APIExplorer.
https://developer.intuit.com/apiexplorer?apiname=V3QBO
Thanks
Simply collect the Error Message coming from Quickbook API. Make following the first catch block statement:
catch (Intuit.Ipp.Exception.IdsException ex)
{
string errorMessage = (((Intuit.Ipp.Exception.ValidationException)(ex.InnerException)).InnerExceptions.FirstOrDefault() ?? new Exception()).Message;
// you can further log the error .
}

servicestack - caching a service response using redis

I have a servicestack service which when called via the browser (restful) Url ex:http://localhost:1616/myproducts, it works fine.
The service method has RedisCaching enabled. So first time it hits the data repository and caches it for subsequent use.
My problem is when I try calling it from a c# client via Soap12ServiceClient. It returns the below error:
Error in line 1 position 183. Expecting element '<target response>'
from namespace 'http://schemas.datacontract.org/2004/07/<target namespace>'..
Encountered 'Element' with name 'base64Binary',
namespace 'http://schemas.microsoft.com/2003/10/Serialization/'.
Below is my Client code:
var endpointURI = "http://mydevelopmentapi.serverhostingservices.com:1616/";
using (IServiceClient client = new Soap12ServiceClient(endpointURI))
{
var request = new ProductRequest { Param1 = "xy23432"};
client.Send<ProductResponse>(request);
}
It seems that the soapwsdl used is giving the problem, but I appear to have used the defaults as generated by servicestack..
Any help will be much appreciated.
Update
I was able over come this error by changing the cache code at the service end:
Code that returned error at client end:
return RequestContext.ToOptimizedResultUsingCache(this.CacheClient, cacheKey,
() =>
new ProductResponse(){CreateDate = DateTime.UtcNow,
products = new productRepository().Getproducts(request)
});
Code that works now:
var result = this.CacheClient.Get<ProductResponse>(cacheKey);
if (result == null)
{
this.CacheClient.Set<ProductResponse>(cacheKey, productResult);
result = productResult;
}
return result;
But I am still curious to know why the first method (RequestContext.ToOptimizedResultUsingCache) returned error at c# client?
But I am still curious to know why the first method (RequestContext.ToOptimizedResultUsingCache) returned error at c# client?
From what I can tell, the ToOptimizedResultUsingCache is trying to pull a specific format (xml, html, json, etc) out of the cache based on the RequestContext's ResponseContentType (see code here and here). When using the Soap12ServiceClient the ResponseContentType is text/html (not sure if this is correct/intentional within ServiceStack). So what ToOptimizedResultUsingCache is pulling out of the cache is a string of html. The html string is being returned to the Soap12ServiceClient and causing an exception.
By pulling directly out of the cache you are bypassing ToOptimizedResultUsingCache's 'format check' and returning something the Soap12ServiceClient can handle.
** If you are using Redis and creating your key with UrnId.Create method you should see a key like urn:ProductResponse:{yourkey}.html
Thanks for your response paaschpa.
I revisited the code and I was able to fix it. Since your response gave me the direction, I have accepted your answer. Below is my fix.
I moved the return statement from RequestContext to the response DTO.
Code which throws error when used via c# client (code was returning entire requestcontext):
return RequestContext.ToOptimizedResultUsingCache(this.CacheClient, cacheKey,
() =>
new ProductResponse(){CreateDate = DateTime.UtcNow,
products = new productRepository().Getproducts(request)
});
Fixed Code (return moved to response DTO):
RequestContext.ToOptimizedResultUsingCache(this.CacheClient, cacheKey,
() => {
return new ProductResponse(){CreateDate = DateTime.UtcNow,
products = new productRepository().Getproducts(request)
}
});

ServiceStack: removing StackTrace from ResponseStatus

I know the same question has been asked here : How to remove the stacktrace from the standard ServiceStack error respose
but it does not matter whatever I tried , I could not remove the StackTrace from ResponseStatus even on remote requests.
SetConfig(new EndpointHostConfig { DebugMode = false, });
is not working or I could not make it work.Any advice could be very helpful.
thnx
This does in-fact work as expected. This is the LOC that makes it so:
if (EndpointHost.UserConfig.DebugMode)
{
// View stack trace in tests and on the client
responseStatus.StackTrace = GetRequestErrorBody() + ex;
}

AWS: Getting 400 Bad Request error from AmazonCloudWatch.GetMetricStatistics()

I'm having a little trouble using AmazonCloudWatch to fetch CPU Utilization. When I try to use AmazonCloudWatch.GetMetricStatistics(), I get this for an exception message:
Exception of type 'Amazon.CloudWatch.AmazonCloudWatchException' was thrown.
And this for an inner exception:
{"The remote server returned an error: (400) Bad Request."}
Here is the code I'm using to make the call:
public static String getCPUStats(String Endpoint, String InstanceID)
{
try
{
AmazonCloudWatchConfig cloudConfig = new AmazonCloudWatchConfig();
cloudConfig.ServiceURL = Endpoint;
string AWSAccessKey = Sql.ToString(appConfig["AWSAccessKey"]);
string AWSSecretKey = Sql.ToString(appConfig["AWSSecretKey"]);
AmazonCloudWatch client = AWSClientFactory.CreateAmazonCloudWatchClient(AWSAccessKey, AWSSecretKey, cloudConfig);
GetMetricStatisticsRequest request = new GetMetricStatisticsRequest();
request.Dimensions.Add(new Dimension { Name = "InstanceId", Value = InstanceID });
request.StartTime = DateTime.UtcNow.AddMinutes(-5);
request.EndTime = DateTime.UtcNow;
request.Namespace = "AWS/EC2";
request.Statistics.Add("Maximum");
request.Statistics.Add("Average");
request.MetricName = "CPUUtilization";
request.Period = 60;
GetMetricStatisticsResponse r = client.GetMetricStatistics(request);
if (r.GetMetricStatisticsResult.Datapoints.Count > 0)
{
Datapoint dataPoint = r.GetMetricStatisticsResult.Datapoints[0];
return "CPU maximum load: " + dataPoint.Maximum;
}
return "No data available.";
}
catch (Exception ex)
{
return ex.Message;
}
}
Some side notes - the access key, secret access key, and endpoint work fine for creating an AmazonEC2Client, so I'm pretty sure the problem isn't there.
I've done quite a bit of googling and poring over the documentation, but haven't been successful in solving this. Any ideas? Thanks so much!
Unfortunately, we weren't able to figure this one out - we ended up deciding to use Microsoft Azure instead of Amazon Web Services :(
I think you can only request one Statistics at a time. So try removing either request.Statistics.Add("Maximum"); or request.Statistics.Add("Average");

Resources