Hello,
I’m currently trying to create a webhook for a project, but I do not get the X-Hook-Secret to return it, and then I get the status 400 and the error message
{
“errors”: [
{
“message”: “The remote server did not respond with the handshake secret.”,
“help”: “For more information on API status codes and how to handle them, read the docs on errors: Build an app with Asana”
}
]
}
Is it a known problem?
Can you maybe share the code you are using?
Yes!
I’m developing in Perl and doing integration with OTRS software.
my $EndPoint = $ConfigObject->Get('AsanaIntegration::Core::EndPoint');
my $Token = $ConfigObject->Get('AsanaIntegration::Core::AccessToken');
# get projects
my $Method = "/webhooks";
my $RequestURL = $EndPoint.$Method;
my $Hook = {
"data" => {
"resource" => *ProjectID*,
"target" => "https://domain/"
}
};
my $JSONBody = $JSONObject->Encode(
Data => $Hook,
);
my $ResponseHook = $Self->WebServiceRequest(
RequestURL => $RequestURL,
AccessToken => $Token,
Type => 'POST',
Body => $JSONBody,
);
This is my function WebServiceRequest:
sub WebServiceRequest {
my ( $Self, %Param ) = @_;
# check needed stuff
if ( !$Param{RequestURL} ) {
$Kernel::OM->Get('Kernel::System::Log')->Log(
Priority => 'error',
Message => "Need RequestURL!",
);
return;
}
# get object
my $JSONObject = $Kernel::OM->Get('Kernel::System::JSON');
my $UserAgent = LWP::UserAgent->new;
my $Authorization = "Bearer ". $Param{AccessToken};
my $Request = HTTP::Request->new($Param{Type} => $Param{RequestURL});
$Request->header('Authorization' => $Authorization);
if(exists $Param{Body}){
$Request->content(encode('UTF-8', $Param{Body}));
}
my $Return;
my $Response = $UserAgent->request($Request);
if ($Response->is_success) {
my $Message = decode( 'UTF-8', $Response->decoded_content);
if(defined $Message){
$Return = $JSONObject->Decode(
Data => $Message,
);
}
}
else {
my $Errors = $JSONObject->Decode(
Data => $Response->decoded_content,
);
$Return->{Code} = $Response->code;
$Return->{Message} = $Errors->{errors};
}
return $Return;
}
But in my target I did not receive the secret handshake
I don’t have an idea sorry. @Phil_Seeman any idea?
I suppose you read everything on Build an app with Asana ?
I’m afraid I don’t know Perl so am not going to be able to make specific suggestions, but in terms of what seems to be happening based on your description…
This indicates that from Asana’s point of view, it received your initial webhook-creation request, it sent out its confirmation POST with an X-Hook-Secret
value, then it waited for you to return that X-Hook-Secret
and it never got it back from you.
Now you’re saying that you didn’t receive its confirmation POST. Again I don’t know Perl but I don’t see anything in your code where you’re accepting a message, checking for the presence of an X-Hook-Secret
Header, and if you find it, returning it back. You’ll need to do that somewhere; is it there and I just don’t see it or (entirely possible!) don’t properly understand your code?
1 Like