Hi Team I need to configure webhook on provider in...
# general
r
Hi Team I need to configure webhook on provider in gitlab. Gitlab supports data only in form of form variables. How can I configure webhook to send form data? I tried following
Copy code
curl --location --request POST '<https://pact-broker.rcue102.viatorsystems.com/webhooks/consumer/event-service>' \
--header 'Content-Type: application/json' \
--data-raw '{
 "consumer": {
    "name": "event-service"
  },
  "provider": {
    "name": "product-service"
  },
  "request": {
    "method": "POST",
    "url": "<https://gitlab.dev.tripadvisor.com/api/v4/projects/{id}/trigger/pipeline>",
    "headers": {
      "Accept": "multipart/form-data"
    },
    "body": {
      "token": "TOKEN",
      "ref": "develop",
      "PIPELINE_LIBRARIES": "contract_verification,no_common",
      "PACT_CONSUMER_TAG": "${pactbroker.consumerVersionTags}"
    }
  },
  "events": [
    {
      "name": "contract_content_changed"
    }
  ]
}
'
curl i need to call is:
Copy code
curl --request POST \
  --form token=TOKEN \
  --form ref=develop \
  --form "variables[PIPELINE_LIBRARIES]=contract_verification,no_common" \
  "<https://gitlab.dev.tripadvisor.com/api/v4/projects/${PROJECT_ID}/trigger/pipeline>"
m
Multipart values presumably would go in the body as key/value pairs
i.e. it’s not JSON
r
yes so above curl should be correct?
🤷‍♂️ 1
but gitlab is not receiving form data
m
from the curl or the webhook?
r
from the webhook
m
right
the webhook is posting JSON, not form values
r
do you have any example how i can pass key value pairs?
i thought i sent key value pair in body
can you format this request, how you think it might work
Copy code
"request": {
    "method": "POST",
    "url": "<https://gitlab.dev.tripadvisor.com/api/v4/projects/{id}/trigger/pipeline>",
    "headers": {
      "Accept": "multipart/form-data"
    },
    "body": {
      "token": "TOKEN",
      "ref": "develop",
      "PIPELINE_LIBRARIES": "contract_verification,no_common",
      "PACT_CONSUMER_TAG": "${pactbroker.consumerVersionTags}"
    }
  },
m
that’s json
body: “key=value&key2=val2…”
I’ll leave it with you to experiment from there.
r
i tried it as above thinking it might work as query param
it did not work either
let me paste curl i tried
Copy code
curl --location --request POST '<https://pact-broker.rcue102.viatorsystems.com/webhooks/consumer/event-service>' \
--header 'Content-Type: application/json' \
--data-raw '{
 "consumer": {
    "name": "event-service"
  },
  "provider": {
    "name": "product-service"
  },
  "request": {
    "method": "POST",
    "url": "<https://gitlab.dev.tripadvisor.com/api/v4/projects/p1/trigger/pipeline?token=TOKEN&ref=develop&PACT_CONSUMER_TAG=${pactbroker.consumerVersionTags}&PIPELINE_LIBRARIES=contract_verification,no_common>",
    "headers": {
      "Accept": "multipart/form-data"
    }
  },
  "events": [
    {
      "name": "contract_content_changed"
    }
  ]
}
'
is the above request similar to what you thought?
m
no, the key value pairs need to be on the
body
👀 1
it might be worth you googling how multipart forms are sent over HTTP. I think it will help you construct the webhook
r
checking
i did check before asking, most of them are suggesting curl, or sending as data but will try to check more
m
sure but curl is a specific tool, the broker doesn’t use curl to send these requests