# Org-roam-protocol not appending body

**URL:** <https://org-roam.discourse.group/t/org-roam-protocol-not-appending-body/2694>\
**Category:** Troubleshooting\
**Created:** [July 9, 2022, 8:11am UTC](https://org-roam.discourse.group/t/org-roam-protocol-not-appending-body/2694 "2022-07-09T08:11:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anoopd](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/anoopd/32/1162_2.png) [@anoopd](https://org-roam.discourse.group/u/anoopd)\
**Post date:** [July 9, 2022, 8:11am UTC](https://org-roam.discourse.group/t/org-roam-protocol-not-appending-body/2694/1 "2022-07-09T08:11:13Z")

</div>

I am using org-roam-protocol with mac Catalina along with roam-ref protocol . I have a bookmarklet with the following code

```auto
javascript:location.href =
    'org-protocol://roam-ref?template=r&ref='
    + encodeURIComponent(location.href)
    + '&title='
    + encodeURIComponent(document.title)
    + '&body='
    + encodeURIComponent(window.getSelection())

```

When i click the bookmark everything works as expected other than `body` part . The selected text is not being displayed . If i change the code to

```auto
javascript:location.href =
    'org-protocol://roam-ref?template=r&ref='
    + encodeURIComponent(location.href)
    + '&title='
    + encodeURIComponent(window.getSelection())

```

The `title` becomes the selected text . ie; window.getSelection is working but `body` part is not working . Do anybody have any idea on what is going on and what have i done wrong ?

---

<div class="post-metadata">

**Author:** ![nobiot](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/nobiot/32/159_2.png) [@nobiot](https://org-roam.discourse.group/u/nobiot)\
**Post date:** [July 9, 2022, 10:32am UTC](https://org-roam.discourse.group/t/org-roam-protocol-not-appending-body/2694/2 "2022-07-09T10:32:22Z")

</div>

I suggest you `edebug` the function `org-roam-protocol-open-ref` – I don’t use `org-roam-protocol` but it appears the body is expected in the code. You should be able to track down what’s happening with the text in the body parameter coming from the browser.

---

<div class="post-metadata">

**Author:** ![jefarr](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@jefarr](https://org-roam.discourse.group/u/jefarr)\
**Post date:** [January 9, 2023, 11:32pm UTC](https://org-roam.discourse.group/t/org-roam-protocol-not-appending-body/2694/3 "2023-01-09T23:32:26Z")

</div>

I’ve found the same issue while trying to set this up, following the steps in [the manual](https://www.orgroam.com/manual.html#org_002droam_002dprotocol).

I’m still learning elisp so my debugging skills are limited, but this is what I’ve found so far:

Set debug-on-entry:

```auto
(debug-on-entry 'org-roam-protocol-open-ref) 

```

Then run this from a shell:

```auto
  /usr/local/bin/emacsclient --no-wait \
    org-protocol://roam-ref\?ref=debug-protocol-body\&title=test-protocol-body-title\&body=foobody

```

> org-roam-protocol-open-ref((:ref “debug-protocol-body” :title “test-protocol-body-title” :body “foobody”))

This doesn’t really help much yet, but it at least shows that the body param is making it into the function.

Total stab in the dark: maybe my capture template is missing something that gives the body a place to go? Currently I’m using an unmodified default template.

---

<div class="post-metadata">

**Author:** ![jefarr](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@jefarr](https://org-roam.discourse.group/u/jefarr)\
**Post date:** [January 18, 2023, 10:23pm UTC](https://org-roam.discourse.group/t/org-roam-protocol-not-appending-body/2694/4 "2023-01-18T22:23:51Z")

</div>

Ok, it took some head scratching and learning but I’ve figured out what this issues is, and it’s not a bug but a combination of things which are probably not obvious to someone new to org mode (and emacs in general).

My suspicion that the root issue with `body` not showing up in the capture was becasue the template didn’t specificy a place to put “body” seems correct. There’s no default assumption or logic to put a parameter named “body” in capture.

It would have been easy going to prove this, but I also got seriously confused by the difference between `org-roam-capture-templates` and `org-roam-capture-ref-templates`. org-roam-protocol requires making changes to the ref templates in order to specify a place for `body`. Here’s a simple example:

```auto
  (setq org-roam-capture-ref-templates
        '(("r" "ref" plain
          "%?"
          :target
          (file+head "${slug}.org" "#+title: ${title}\n${body}")
          :unnarrowed t)))

```

While initially this was unintuitive, I’m really excited about how flexible this is. In combination with the templating engine this provides the basis of some powerful capture!
