user1485267
user1485267

Reputation: 1335

amazon dynamodb through rest api

which are the required headers we need to send in the header using dynamodb rest api

'x-amz-date': 'Mon, 16 Jan 2012 17:50:52 GMT',
'x-amzn-authorization': 'AWS3 AWSAccessKeyId=TemporaryAccessKeyID,Algorithm=HmacSHA256,SignedHeaders=Host;x-amz-date;x-amz-target;x-amz-security-token,Signature=*Signature Value*=',
'Date': 'Mon, 31 Oct 2011 17:49:52 GMT',
'x-amz-target': 'DynamoDB_20111205.GetItem',
'x-amz-security-token': '*Token Value*',
'Content-Type': 'application/x-amz-json-1.0',
'Content-Length': '135',
'Connection': 'Keep-Alive',
'User-Agent': 'aws-sdk-java/1.2.10 Windows_7/6.1 Java_HotSpot(TM)_64-Bit_Server_VM/20.2-b06',
}

can i know what are all the required parameters we need to pass through http rest api for dynamo ... I need to fetch the data from dynamodb database??? can anyone suggest what are required headers link

Upvotes: 3

Views: 2401

Answers (1)

mingfai
mingfai

Reputation: 1075

It's not yet a year since the question is asked so I hope it's not too late to answer. :-)

One of the best ways to find out which HTTP header field is required is to use the AWS SDK. This approach is recommended by AWS. (according to a forum post by an @AWS guy) You may:

  1. Enable DEBUG log for AWS's package (e.g. com.amazonaws) and optional Apache HTTP Client (e.g. org.apache.http) to see. One straightforward way it to configure log4j. Personally, i use slf4j-over-jcl and then configure logback.xml
  2. Write a simple program that request DynamoDB, make sure the result is correct, and look at the log

For example, in a ListTables request, the following Headers are used:

  • Content-Length
  • Content-Type
  • Host
  • User-Agent
  • X-Amz-Date
  • X-Amz-Target

Notice that the HTTP header shall be capitalized. The log also show the signature that are turned to lower case. "Content-Length" and "User-Agent" are optional, the other fields are mandatory. "Content-Type" can be "application/json" if you don't like "x-amz-json-1.0".

It seems to me there are two tricky parts to implement our own REST client, one is do the signature right, the other is to get the headers right. For the signature part, AWS provides a test suite that allows us to verify our signature implementation.

Upvotes: 2

Related Questions