Hi! I am having trouble creating a webhook. For c...
# pact-broker
s
Hi! I am having trouble creating a webhook. For context - we are using Dockerized pact broker. I am following the pact nirvana guide and I'm currently at the Platinum stage, where I'm implementing can-i-deploy to PR pipelines. I've created a separate CI job (in Jenkins, TWIMC), and I got to the webhook creation step. I tried two methods: 1- pact-broker CLI
pact-broker create-webhook <http://www.google.com|www.google.com> -X POST --broker-base-url=https://<our-broker-url> --contract-content-changed --broker-username=<username> --broker-password=<password> --verbose
2- curl/postman
curl --location --request POST 'https://<our-broker-url>/webhooks/consumer/<consumer-name>' \
--header 'Authorization: Basic <encoded username:password>'
Both options eventually give me 401 unauthorized. I have double-checked the credentials and they are good. IDK what I am doing wrong here and the issues found online about 401 issues mostly suggest using tokens instead of basic auth, which we do not have as we're using the self-hosted broker. Another issue I found simply said "already fixed" πŸ˜…
βœ… 1
y
Are you sending a webhook payload?
--data
?
s
I am not. I tried with minimal setup, so no content
I tried now to add
--data="{'foo': 'bar'}"
to the CLI command, but no luck, still 401
y
Copy code
pact-broker create-webhook <http://www.google.com|www.google.com> -X POST --broker-base-url=<http://localhost:9292> --contract-content-changed --verbose
returns
Copy code
Error creating webhook. response status=400 body={"errors":{"request.url":["is not a valid URL eg. <http://example.org>"]}}
Copy code
pact-broker create-webhook <https://www.google.com> -X POST --broker-base-url=<http://localhost:9292> --contract-content-changed --verbose
returns
Copy code
Webhook "POST <http://www.google.com|www.google.com>" created
s
Copy code
pact-broker create-webhook <https://www.google.com> -X POST --broker-base-url=https://<broker_url> --contract-content-changed --broker-username=user --broker-password=pass --verbose
Error creating webhook. response status=401
y
I’ll add auth to my broker and check
πŸ™Œ 1
s
Thx! FWIW:
Copy code
pact-broker version
1.75.3
Oh, maybe I can try the --user field instead Still 401 πŸ˜•
y
hmm just setup the latest oss docker image with basic auth, and was able to send it fine thinking
Copy code
pact-broker create-webhook <https://www.google.com> -X POST --broker-base-url=<http://localhost:9292> --contract-content-changed --verbose --broker-username test --broker-password test
s
Hmmm
y
just a
docker-compose up
in https://github.com/pact-foundation/pact-broker-docker after adding these env vars in in the
pact-broker
service
Copy code
PACT_BROKER_BASIC_AUTH_USERNAME: test
    PACT_BROKER_BASIC_AUTH_PASSWORD: test
is there any other infra set up between your broker at all? is the webhooks endpoint say blocked as at reverse proxy layer?
s
I'll ask our infra guys and check the broker logs to investigate deeper. Thx for at least confirming that I was on the correct path with the webhook creation myself
y
s’all good Siim. Good luck on the path to pact nirvana πŸ‘ ps. I would very much recommend this webhook
contract_requiring_verification_published
event over the
contract_content_changed
https://docs.pact.io/pact_broker/webhooks#the-contract-requiring-verification-published-event
πŸ™Œ 1
s
Yea, I was looking at that indeed. Just wanted to create any webhook as a start to fiddle around
y
Yeah totally understand. I did add a section for testing out broker webhooks locally in our pact-js workshop, which may be worth a look at https://github.com/pact-foundation/pact-workshop-js/tree/step12#step-12---using-webhooks to give you a nice playground outside of your production broker πŸ‘
s
Before coming here with my question I stumbled upon this page as well πŸ˜„ But seeing "step 12" and already having been through the PoC phase good amount of time ago, I figured I'll keep chipping at our current setup instead of investing time in the workshop right now.
But very nice to have a workshop like this πŸ‘
@Yousaf Nabi (pactflow.io) for context, what is your output for
pact-broker version
The funniest and most classical dev blunder had happened. For some reason, somewhere, somehow, the special characters got URL decoded. I have no idea where in the process this happened. So our gibberish password, something like
kr#wREWre$wqRtT&wqe
I had somehow turned into
kr%23wREWre%24wqRtT%26wqe
And I had no idea what I was doing wrong and kept pasting the wrong password πŸ˜‚
πŸ˜… 2
headdesk 1
y
hehe, happens to us all. at least you are sorted! woohoo
πŸ™Œ 1