1
When running ->sns->Publish I have the following error:
Error executing "Publish" on "https://sns.us-west-2.amazonaws.com"; AWS HTTP error: Client error: `POST https://sns.us-west-2.amazonaws.com` resulted in a `400 Bad Request` response:
<ErrorResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
<Error>
<Type>Sender</Type>
<Code>InvalidPara (truncated...)
InvalidParameter (client): Invalid parameter: TargetArn Reason: ARN specifies an invalid endpointId: UUID must be encoded in exactly 36 characters. -
<ErrorResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
<Error>
<Type>Sender</Type>
<Code>InvalidParameter</Code>
<Message>Invalid parameter: TargetArn Reason: ARN specifies an invalid endpointId: UUID must be encoded in exactly 36 characters.</Message>
</Error>
<RequestId>a634effa-XXXX-XXXX-XXXX-bfeb15b8XXXX</RequestId>
</ErrorResponse>
By performing various tests and debugging the variable values, I print the variable that stores the client’s codarn ($target) and it’s OK. I even copied the value of the variable and then put it directly in the method to which I implement the upload and worked normally. Only when I pass the value as parameter does the error occur. This is my implemented method:
public function publishMessage($target, $message) {
try {
$result = $this->sns->publish([
'MessageStructure' => 'json',
'Message' => $message,
'TargetArn' => $target,
]);
} catch (\Aws\Sns\Exception\SnsException $exc) {
echo $exc->getMessage();
return false;
}
return $result;
}
PS: the XXX in Requestid is purposeful and to keep confidential the value of the client’s codarn.