# HTML not working i log note field from API

**URL:** <https://farmos.discourse.group/t/html-not-working-i-log-note-field-from-api/1846>\
**Category:** Development\
**Created:** [January 21, 2024, 10:23pm UTC](https://farmos.discourse.group/t/html-not-working-i-log-note-field-from-api/1846 "2024-01-21T22:23:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [January 21, 2024, 10:23pm UTC](https://farmos.discourse.group/t/html-not-working-i-log-note-field-from-api/1846/1 "2024-01-21T22:23:50Z")

</div>

Trying to add some logs with a bit of statistics in the notes field of an oversvation log via the API.

HTML seems to work only if I type it directly in the notes field.  
I think I’ve paid notice of this before, but cant remember or find it.

Is it a bug, or do I have to add something more in the json?

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [January 22, 2024, 11:03am UTC](https://farmos.discourse.group/t/html-not-working-i-log-note-field-from-api/1846/2 "2024-01-22T11:03:48Z")

</div>

@pat Can you share an example of the JSON you are trying to POST?

You may need to include `"format": "default"` alongside the `"value"` property of the `notes` field, if you aren’t already, like this:

```auto
...
"notes": {
  "value": "These are my notes.",
  "format": "default"
},
...

```

Drupal allows different “text formats”, and each defines what “filters” are enabled on them. The `default` format has a filter that allows certain HTML tags.

So if the log you are creating via API doesn’t have `"format": "default"` then that would explain why your HTML doesn’t work. Take a look at the log’s JSON to check.

Despite the name `default`, this text format is actually not a Drupal default. It is provided by farmOS, and we set it as the default text format on logs and assets. But perhaps it doesn’t use it automatically if you omit `format` in the API JSON.

---

<div class="post-metadata">

**Author:** ![pat](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/pat/32/1050_2.png) [@pat](https://farmos.discourse.group/u/pat)\
**Post date:** [January 22, 2024, 12:39pm UTC](https://farmos.discourse.group/t/html-not-working-i-log-note-field-from-api/1846/3 "2024-01-22T12:39:58Z")

</div>

> [@mstenta](#):
>
> You may need to include `"format": "default"` alongside the `"value"` property of the `notes` field,

That was it..

Thanks. I’ve seen this before.. 🫢

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [January 22, 2024, 12:59pm UTC](https://farmos.discourse.group/t/html-not-working-i-log-note-field-from-api/1846/4 "2024-01-22T12:59:03Z")

</div>

Great!

It does beg the question: should farmOS try to automatically set the `format` if it isn’t included in API requests? That would match UI behavior…

I’m not exactly sure how to do that in farmOS code, or if it’s possible, but there’s probably a way. 🤷
