When executing the method - > 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 doing several tests and debugging the variable values, I print the variable that stores the client's code ($ target) and it is OK. I copied the value of the variable and then put it directly into the method to which it was uploading and worked normally . Only when I pass the value as a 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 the RequestId is intentional and to keep the codarn value of the client confidential.