Empty Webhook Body?
# support
s
I configured a Subscription listening to Patient updates with a rest-hook. I'm successfully receiving webhooks but with an empty post body. I assume I'm missing something simple here. I'm using an ngrok URL to forward the webhooks to my test environment, where I'm using NodeJS 16, Express, and body-parser. Subscription ID: fa3496e0-c1cd-4bc4-8ef2-6f441814b7bb Screenshot attached This is set up in a free / hosted account, in case that has any related limitations. Thanks!
r
Sorry for the delay here! If you go to https://app.medplum.com/Subscription//event what do you see?
Is it possible that the resource was deleted?
However, there's a specific scenario where the webhook post body would be empty. This happens when a resource is deleted.
s
I see a list of entries that look like this. The hook was triggered by a Patient update as far as I can tell
r
Have not forgotten about this - trying to repro!
s
Appreciate the update. Let me know if there's anything I can do to help around repro steps
r
@sebasstellescope to help us debug, would you mind trying to send your subscription to Pipedream? It's a free service that can be used to inspect the payload of the webhooks.
I've actually set up an account myself, so I can also inspect your payloads if you want to point your subscription to this URL: https://32712318bceb5e907387726f35be0618.m.pipedream.net
Then i can inspect the payload on your behalf
s
Just transmitted to that URL
r
I just received a payload. Are you comfortable if I share the results here?
I just want ot make sure this Patient doesn't contain any sensitive data, like PII / PHI
s
You can share it's all unsensitive data
r
Copy code
{
  "method": "POST",
  "path": "/",
  "query": {},
  "client_ip": "34.230.144.238",
  "url": "https://32712318bceb5e907387726f35be0618.m.pipedream.net/",
  "headers": {
    "host": "32712318bceb5e907387726f35be0618.m.pipedream.net",
    "content-length": "567",
    "content-type": "application/fhir+json",
    "accept": "*/*",
    "user-agent": "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)",
    "accept-encoding": "gzip,deflate"
  },
  "bodyRaw": "{\"resourceType\":\"Patient\",\"active\":true,\"name\":[{\"given\":[\"Test\"],\"family\":\"Patient\",\"suffix\":[\"2!\"]}],\"id\":\"e0c82ae0-f004-4a65-a86d-5fca5bae5d1a\",\"meta\":{\"versionId\":\"b4f962bb-c2e7-43ab-ad6e-0aa5dfcbfdf5\",\"lastUpdated\":\"2023-09-07T23:55:18.410Z\",\"author\":{\"reference\":\"Practitioner/8d625908-e726-4d94-8636-8ba6324f2264\",\"display\":\"Sebastian Coates\"},\"project\":\"54f52788-6cac-4a42-be63-034165334f7b\",\"compartment\":[{\"reference\":\"Project/54f52788-6cac-4a42-be63-034165334f7b\"},{\"reference\":\"Patient/e0c82ae0-f004-4a65-a86d-5fca5bae5d1a\",\"display\":\"Test Patient 2!\"}]}}",
  "body": {
    "resourceType": "Patient",
    "active": true,
    "name": [
      {
        "given": [
          "Test"
        ],
        "family": "Patient",
        "suffix": [
          "2!"
        ]
      }
    ],
    "id": "e0c82ae0-f004-4a65-a86d-5fca5bae5d1a",
    "meta": {
      "versionId": "b4f962bb-c2e7-43ab-ad6e-0aa5dfcbfdf5",
      "lastUpdated": "2023-09-07T23:55:18.410Z",
      "author": {
        "reference": "Practitioner/8d625908-e726-4d94-8636-8ba6324f2264",
        "display": "Sebastian Coates"
      },
      "project": "54f52788-6cac-4a42-be63-034165334f7b",
      "compartment": [
        {
          "reference": "Project/54f52788-6cac-4a42-be63-034165334f7b"
        },
        {
          "reference": "Patient/e0c82ae0-f004-4a65-a86d-5fca5bae5d1a",
          "display": "Test Patient 2!"
        }
      ]
    }
  }
}
I think the issue might lie with
body-parser
. Makes ure you're handling content-type
application/fhir+json
s
Ok great thanks for the help. I had tried logging the raw request without using body-parser or any middleware, and wasn't seeing anything. But I can try again. And worst case, I can set up my own pipedream account for testing
bodyParser.json({ type: 'application/fhir+json' }) looks like it does the trick! Thanks again for the help, I really appreciate it
r
Great! Glad it worked
c
So thankful to have found this question! Also felt a total DOH moment when we realized we needed the parser
323 Views