Hi,
I have updated my code a bit & Now I get following error message. I have updated my PowerBuilder code as well below. Pls help!
<?xml version="1.0"?><ErrorResponse xmlns="http://queue.amazonaws.com/doc/2010-05-08
/"><Error><Type>Sender</Type><Code>MalformedVersion</Code><Message>Version not well formed: 2010-05-08
. Must be in YYYY-MM-DD format.</Message><Detail/></Error><RequestId>e96ee9d8-f694-5229-98a6-b2e5e20b8c5b</RequestId></ErrorResponse>
Regards,
Vishalakshi
Integer li_rc
RestClient lnv_RestClient
ResourceResponse lrr_response
String ls_url, ls_response, ls_auth, ls_secret_key, ls_host, ls_signing_key, ls_access_key, ls_string_to_sign
Blob lblb_signing_key, lblb_string_to_sign
String ls_utcdate
httpclient lhttp_client
lhttp_client = CREATE httpclient
CoderObject lnv_CoderObject
lnv_CoderObject = Create CoderObject
CrypterObject lnv_CrypterObject
lnv_CrypterObject = Create CrypterObject
ls_access_key = 'XXXXXX'
ls_secret_key = 'XXXXX'
ls_host = 'sqs.ap-south-1.amazonaws.com'
SELECT CURRENT UTC TIMESTAMP INTO :ls_utcdate FROM DUMMY; //SQL ANYWHERE DB
ls_utcdate = String(ls_utcdate, "YYYYMMDD") + "T" + String(ls_utcdate, "HHMMSS") + "Z"
ls_string_to_sign = "AWS4-HMAC-SHA256"+Left(ls_utcdate, 8)+"/ap-south-1/sqs/aws4_request"
lblb_string_to_sign = lnv_CrypterObject.SHA(SHA256!, Blob(ls_string_to_sign,EncodingANSI!))
lblb_signing_key = lnv_CrypterObject.HMAC(HMACSHA256!, Blob("AWS4" + ls_secret_key, EncodingANSI!),Blob(Left(ls_utcdate, 8),EncodingANSI!))
lblb_signing_key = lnv_CrypterObject.HMAC(HMACSHA256!, lblb_signing_key, Blob("ap-south-1", EncodingANSI!))
lblb_signing_key = lnv_CrypterObject.HMAC(HMACSHA256!, lblb_signing_key, Blob("sqs", EncodingANSI!))
lblb_signing_key = lnv_CrypterObject.HMAC(HMACSHA256!, lblb_signing_key, Blob("aws4_request", EncodingANSI!))
ls_signing_key = lnv_CoderObject.HexEncode(lnv_CrypterObject.HMAC(HMACSHA256!, lblb_signing_key, lblb_string_to_sign))
ls_auth = "AWS4-HMAC-SHA256 Credential=" + ls_access_key + "/"+Left(ls_utcdate, 8)+"/ap-south-1/sqs/aws4_request,SignedHeaders=host;x-amz-date,Signature="+ls_signing_key
lhttp_client.SetRequestHeader( "content-type","application/x-www-form-urlencoded"+"~n")
lhttp_client.SetRequestHeader("x-amz-date", ls_utcdate+"~n")
lhttp_client.SetRequestHeader("host", ls_host+"~n")
lhttp_client.SetRequestHeader("authorization", ls_auth+"~n")
ls_url = "https://sqs.ap-south-1.amazonaws.com/123456653804/maven-notification-maven-8?Action=ReceiveMessage&Version=2012-11-05"+"~n"
li_rc = lhttp_client.SendRequest("GET", ls_url)
ls_response = lhttp_client.GetResponseStatusText()
//if li_rc = 1 and lhttp_client.GetResponseStatusCode() = 200 then
lhttp_client.GetResponseBody(ls_response)
//end if
DESTROY lhttp_client
DESTROY lnv_CoderObject
DESTROY lnv_CrypterObject
RETURN ls_response