I'm using AWS CloudSearch SDK Java (aws-java-sdk-cloudsearch 1.11.288)to upload document to CloudSearch. But it throws this exception:
AmazonCloudSearchDomainException: null (Service: AmazonCloudSearchDomain; Status Code: 411; Error Code: null...
Still not find the solution for that issue. I can upload the same json data using AWS Cloudsearch CLI.
How can I get over this exception?
Thanks.
The AWS documentation says that a request to upload documents will receive a response with the 411 status code when it is missing the Content-Length header.
Make sure to set the content length by calling the setContentLength() method on the UploadDocumentsRequest object with the appropriate value for your request.
Related
I have created a React Application to upload a file to the S3 bucket. To do this, I have created a PUT API from the AWS API Gateway and the API is working well in the POSTMAN. The problem is, when I call the API from my React Application locally (http://localhost:3000), I'm getting a 500 error from the OPTIONS request (Preflight).
I have set the Binary Media Types to "image/jpeg" and When I remove the Binary Media Types, the API returns the 200 response, but then, an empty image is uploaded without its content.
How can I solve this?
This is my Request Integrations of both the PUT method and the OPTIONS method
PUT
OPTIONS
Binary Media Types
What am I missing here?
I'm able to list objects no problem using the aws cli and this command:
aws s3 ls s3://bucket.mycompany.com/parent-dir1/parent-dir2/
But using the REST API via Postman, an equivalent request returns an empty response.
Tool: Postman
Method: GET
URl:
https://bucket.mycompany.com.s3.amazonaws.com/parent-dir1/parent-dir2/?list-type=2
Auth:
Headers:
I've tried with no headers and with x-amz-content-sha256 UNSIGNED-PAYLOAD
Message says "This is a duplicate header and will be overridden..." when I try to use this header
Response:
Status 200 but response is empty(There are MANY files in parent-dir2).
Eureka! Found the answer in the AWS docs here
Winner ended up being:
https://bucket.mycompany.com.s3.amazonaws.com/?list-type=2&prefix=parent-dir1/parent-dir2/
I get the following error message when calling actions for CloudWatch in API Gateway.
"Error": {
"Code": "InvalidAction",
"Message": "Could not find operation DescribeAlarms for version 2009-05-15",
"Type": "Sender"
}
I've been using DescribeAlarms for testing. My setup is as follows.
Integration Type = AWS Service
AWS Service = CloudWatch
HTTP method = POST
Action = DescribeAlarms
The error references the API Version 2009-05-15, which only has ListMetrics and GetMetricStatistics according to it's documentation on page 54. ListMetrics does indeed work as expected with my setup.
The current version is 2010-08-01 but I don't see anyway to reference that in API Gateway. In an example of a POST request in the documentation it shows a header labeled x-amz-target with a value of GraniteServiceVersion20100801.API_Name.
My interpretation is I can put Name = x-amz-target and value 'GraniteServiceVersion20100801.DescribeAlarms' in my http header for the Integration Request in API Gateway.
This doesn't change the response and gives the same error message.
I also used the --debug in CLI when calling describe-alarms, and in the body it shows...
"body": {
"Action":"DescribeAlarms",
"Version":"2010-08-01"
}
So I also set http headers to include Content-Type with a value of 'application/x-amz-json-1.1' and then put in
{
"Action":"DescribeAlarms",
"Version":"2010-08-01"
}
but nothing changed with that either.
Any help or guidance would be greatly appreciated.
Under Method Integration -> URL Query String Parameters
I added Version as the Name and '2010-08-01' under Mapped From.
All actions are now working as expected.
I'm trying to PutMetrics directly from Api Gateway -> Cloudwatch using PutMetricData, Version in the query string params didn't work for me.
These 3 HTTP headers in the Integration Request solved it for me:
Content-Type 'application/json'
X-Amz-Target 'GraniteServiceVersion20100801.PutMetricData'
Content-Encoding 'amz-1.0'
I created a API Gateway which is Integrated to use S3 bucket. I see that when I tried to retrieve the object I am getting a 200 response. However I am getting some ackward text(probably a base64 or binary text rather than the image. Can you please let me know the fix.
So the answer is set the following headers:-
AWS Request We are submiting PUT request in Amazon Web Service. But unfortunetly we are getting following error.
AccessDenied There were headers present in the request which were not
signed x-amz-acl, x-amz-server-side-encryption, x-amz-copy-source
Does anyone know how to fix this error?
Note: We are using Amazon Singature Version 4.