Hello, I am re-posting here what I had already ask...
# pact-broker
a
Hello, I am re-posting here what I had already asked above and on StackOverflow without any reply, in an attempt to get some answers from more expert people here. Thank you in advance for any help: I am preparing a demo on the PACT workflow, and as part of it I would like to demonstrate the concept of webhooks. To this extent I created a container with the pact-broker running, I can use the CLI to publish and verify a PACT successfully. Then I can make verification fail introducing a breaking change in the API spec, regenerating objects and re-running the provider app with the breaking changes. Everything works well up to that point. In the last part I would like to enrich the demo showing how to create webhooks to notify a recipient about contract content changed. To this extend I created a small SpringBoot app that exposes a
/notifications
endpoint that I want to use as recipient for the webhook. My current issue is with creation of the webhook, and specifically that attempts at creating the webhook return 401 with the execution line below:
Copy code
docker run --rm --network="host" pactfoundation/pact-cli:latest pact-broker create_webhook <http://localhost:8080/notifications> -X POST -b <http://localhost:9292/webhooks> -u pactBrokerUsername -p pactBrokerUserPassword -d "{\"events\":[{\"name\":\"contract_content_changed\"}],\"request\":{\"method\":\"POST\",\"url\":\"http:/localhost:8080/notifications\",\"headers\":{\"Content-Type\":\"application/json\"},\"body\":{\"some\":\"json\"}}}" --contract-published
In the line above: • http://localhost:9292 is the URL for the PACT broker • http://localhost:8080 is the URL for the recipient of the webhook, the simple app that I want to receive notifications. I formed this line looking at the PACT documentation, however I find quite a lot of what is being said there confusing so evidently something is misplaced or missing. I would appreciate some help with this from whoever has created webhooks before.
y
the base url shouldn’t have /webhooks in it
the pact broker cli knows the subpath, the docs state provide the base url, not the url to the webhook endpoint
a
Thank you. The documentation link below says explicitly "To create a webhook, send a
POST
request to
/webhooks
with the body described below. You can also do a
PUT
to `/webhooks/{uuid}`" https://github.com/pact-foundation/pact_broker/blob/master/lib/pact_broker/doc/views/webhooks.markdown If that is not true then maybe somebody should change it?
y
that is true but you arent using the api
a
Ah, thanks