AWS - SQS - POST Message Attributes - amazon-web-services

I'm currently POSTing a message to an SQS queue with the parameters as x-www-form-urlencoded parameters. I have a requirement to populate specific message attributes. I have been attempting to populate the 'MessageAttributes' as seen below:
I seem to be getting the following error however:
<?xml version="1.0"?>
<ErrorResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/">
<Error>
<Type>Sender</Type>
<Code>MalformedInput</Code>
<Message>Unexpected complex element termination</Message>
<Detail/>
</Error>
<RequestId>ca4990e0-7ba8-5a8f-b29a-cce1ab8e9d6b</RequestId>
</ErrorResponse>
I have also tried Specifying keys for 'MessageAttributes.1.Name' and 'MessageAttributes.1.Value' but I get the same error.
Is there any documentation to show how to specify this for a POST request. I seem to only find material relating to using the AWS SDK.
Cheers,
Duncan.

Related

AWS API Gateway to Simple Notification Service

I'm trying to use the AWS console to pass a message straight from an API Gateway into an SNS queue. All the examples I've seen seem to go via a Lambda, but all the documentation and settings seem to suggest this step isn't necessarily needed.
I've got the below setup, but keep getting the error of
Execution failed due to configuration error: No match for output mapping and no default output mapping configured. Endpoint Response Status Code: 400
The mapping template section has: "When no template matches the request Content-Type header" set which the "Help" section suggests the body (which is where the json string is posted) is passed through if I've got no template set up, but maybe I'm misunderstanding this.
What am I missing?

AWS ECS Api GET query with string array

I'm trying to query the AWS ECS API with a REST GET query using the following:
https://ecs.us-east-1.amazonaws.com/?Action=DescribeServices&services=sample-app-service&cluster=testecscluster&Version=2014-11-13
The response is:
<ErrorResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
<Error>
<Type>Sender</Type>
<Code>MalformedInput</Code>
<Message>Unexpected list element termination</Message>
</Error>
<RequestId>e0a57636-c8c6-11e8-a099-0b02f829db78</RequestId>
</ErrorResponse>
Services is supposed to be an array of strings, but i can't seem to get the URL formatting correct in the URL encoding to work correct.
I've tried a few different methods and can't get the query URL to work. Anyone else have luck passing array in the url request?
I'm testing this in postman here are the headers and params:

Cannot upload document into AWS CloudSearch

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.

How to access twilio's request from the aws api gateway mapping template?

I want to access my twilio get request (body, method, query etc.) via the aws api gateway but i don't know what to put in my aws api gateway in the mapping template to process it.
Any help will be highly appreciated.
Thanks.
If you want the response from the endpoint to be passed through as-is, you can use pass through mapping. Otherwise, you can use the mapping templates to customize the method response. Here is the Mapping Template Reference for API Gateway. Please let us know if you have any specific questions.
This is the most complete answer for AWS API Gateway to convert a form URL encoded POST, to a JSON payload...
Convert URL Encode to JSON NOTE: Scroll down to the last answer, as there are several updated to account for edge cases.
It's a lot of ceremony, using a language that I've never seen before, but at least it's readable. Far cry IMO from Azure functions where you simply get the request, and then manage it with the language that you are in.
This only gets you half way there however, you also have to add a mapping template to the Integration Response - but that template is simple and is referenced in the previous comment - repeated here for convenience
#set($inputRoot = $input.path('$'))
<?xml version="1.0" encoding="UTF-8"?>
<Response>
$inputRoot
</Response>
Since I'm using only responding to an SMS message - I added the following, and only returned a string from the function:
#set($inputRoot = $input.path('$'))
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Message>
<Body>
$inputRoot
</Body>
</Message>
</Response>

URL amazon API - Item lookup not valid for this endpoint

So I'm having trouble making an API request to amazon and returning XML that displays product information, particularly price. I'm using the signed request helper to generate my requests, and have been following the examples in the AWS documentation.
here is my request URL and params:
http://webservices.amazon.com/onca/xml?
Service=AWSECommerceService
&Operation=ItemLookup
&ResponseGroup=OfferFull
&Condition=All
&IdType=ASIN
&ItemId=B001L8NG0Q
the helper also generates my signature, access keys, etc. However this is what is returned what I submit this request:
<ErrorResponse xmlns="http://ecs.amazonaws.com/doc/2005-10-05/">
<Error>
<Code>InvalidAction</Code>
<Message>
The action ItemLookup is not valid for this endpoint.
</Message>
</Error>
<RequestId>a006f1ec-11b3-4afd-a5a3-cb8cfd7e4186</RequestId>
</ErrorResponse>
Any ideas on what my problem is here? I seem to be able to get this to work just fine for keyword queries, but i'm having trouble with this item lookup.