Hello, I am trying to create webhook, but when i test always get error like this
{
"errors": [
{
"message": "The remote server which is intended to receive the webhook 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: https://developers.asana.com/docs/errors"
}
]
}
but in my ngrok logs I’ve done what the documentation says for response, any feedback?
Thanks
HTTP/1.1 200
X-Hook-Secret: ecb0f15e2bbece5546fbcbaea98a1484
Content-Length: 0
Date: Wed, 23 Feb 2022 08:56:54 GMT
this is my response
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.LogManager;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import java.util.logging.Logger;
@RestController
@Slf4j
public class AsanaController {
@RequestMapping("/asana-webhook")
public ResponseEntity handle(@RequestHeader Map<String, String> headers,
@RequestBody String payload) {
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.add("X-Hook-Secret", headers.get("x-hook-secret"));
log.info(headers.get("x-hook-secret"));
String xhook = "X-Hook-Secret: " + headers.get("x-hook-secret");
return new ResponseEntity<>(responseHeaders, HttpStatus.OK);
}
}
and this is my code in java
public ResponseEntity handle(@RequestHeader Map<String, String> headers,
@RequestBody String payload) {
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.set(“X-Hook-Secret”,
headers.get(“x-hook-secret”));
return ResponseEntity.ok()
.headers(responseHeaders)
.body("X-Hook-Secret: "+ headers.get("x-hook-secret"));
}
change my code like this, and now thats ok