# Text choice save error - Request Entity Too Large

**URL:** <https://support.prodi.gy/t/text-choice-save-error-request-entity-too-large/2011>\
**Category:** Uncategorized\
**Tags:** usage, front-end, solved\
**Created:** [September 13, 2019, 2:00pm UTC](https://support.prodi.gy/t/text-choice-save-error-request-entity-too-large/2011 "2019-09-13T14:00:57Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![nuno](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@nuno](https://support.prodi.gy/u/nuno)\
**Post date:** [September 13, 2019, 2:00pm UTC](https://support.prodi.gy/t/text-choice-save-error-request-entity-too-large/2011/1 "2019-09-13T14:00:57Z")

</div>

Hi, I am using the choice interface to annotate text with multiple categories. It has always worked but now it won't let me save after a few annotations (just threw an error when saving 13 examples).

I checked the console and found the error `Failed to load resource: the server responded with a status of 413 (Request Entity Too Large)` , which I've encountered before when annotating images.

I believe this error is due to the large number of options I am setting for this particular task. Is that possible? Is there a way to prevent the options to be saved with the examples? I don't really need them...

Thanks.

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [September 13, 2019, 2:11pm UTC](https://support.prodi.gy/t/text-choice-save-error-request-entity-too-large/2011/2 "2019-09-13T14:11:13Z")

</div>

That's definitely strange. What's in your task, and how many options do you have in there?

It's possible that this error happens when you annotate images, because by default, the image gets converted to a base64 string and if the image is large, that string can get very large, too. So you end up with this _huge_ JSON blob. But in order to create an object this big with only plain text, you'd really need to have _a lot_ of text.

---

<div class="post-metadata">

**Author:** ![nuno](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@nuno](https://support.prodi.gy/u/nuno)\
**Post date:** [September 13, 2019, 2:28pm UTC](https://support.prodi.gy/t/text-choice-save-error-request-entity-too-large/2011/3 "2019-09-13T14:28:37Z")

</div>

Well, I am now using about 500 options 🙄😅 I know it is not the ideal annotation workflow, but it is a requirement for what I am testing at the moment. The documents have the same size as I've always used.

Is there a way to go around this and prevent the options to be saved with each example? Again: it is text and using the choice interface.

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [September 13, 2019, 2:47pm UTC](https://support.prodi.gy/t/text-choice-save-error-request-entity-too-large/2011/4 "2019-09-13T14:47:46Z")

</div>

Okay, this explains a lot 😅

I'm not sure what the best solution would be, because you'd have to remove the options on the client and _before_ they're sent back to the server, right? I guess you could write a hacky script that listens on `prodigyupdate` and if `content.accept` has an entry (an option was selected, assuming it's single choice) it calls `update({ options: [] })`. Seems pretty unsatisfying, though.

To be honest, if this is really the workflow you want, you're probably better off writing a custom interface that uses a dropdown and then updates the task's `accept` on change. This means you'd only have to send over your options once with the HTML template (and not with every task) and you'd probably get a better user experience as well.

---

<div class="post-metadata">

**Author:** ![nuno](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@nuno](https://support.prodi.gy/u/nuno)\
**Post date:** [September 13, 2019, 3:29pm UTC](https://support.prodi.gy/t/text-choice-save-error-request-entity-too-large/2011/5 "2019-09-13T15:29:03Z")

</div>

Thanks Ines. It is indeed a difficult use case.

Do you have any instructions or examples on how to create my own custom interface?

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [September 14, 2019, 9:56am UTC](https://support.prodi.gy/t/text-choice-save-error-request-entity-too-large/2011/6 "2019-09-14T09:56:07Z")

</div>

> [@nuno](#):
>
> Do you have any instructions or examples on how to create my own custom interface?

Check out the section on custom Javascript in the `PRODIGY_README.html`. This thread also has some examples: [Custom view templates with scripts - #6 by ines](https://support.prodi.gy/t/custom-view-templates-with-scripts/302/6)

Essentially, you want your recipe config to return a `html_template` that looks something like this (`{{text}}` will get replaced with the "text" value of the current annotation task):

```html
{{text}}<br /><br />

<select class="dropdown">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<!-- and so on... ->
</select>

```

In your `javascript`, you can then add an event listener to it and update the current task with the selected value. Something like this – untested, but should work:

```javascript
document.addEventListener('prodigymount', event => {
    const dropdown = document.querySelector('.dropdown')
    dropdown.addEventListener('change', event => {
        // dropdown.value is the selected answer
        console.log('Selected:', dropdown.value)
        window.prodigy.update({ accept: [dropdown.value]})
    })
})

```

This is all assuming you only want to allow single selections. If you want multiple selections, you could make it a `<select multiple>` and then [add some logic to read out the selected options](https://stackoverflow.com/questions/1295950/javascript-to-select-multiple-options).

---

<div class="post-metadata">

**Author:** ![nuno](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@nuno](https://support.prodi.gy/u/nuno)\
**Post date:** [September 16, 2019, 9:37am UTC](https://support.prodi.gy/t/text-choice-save-error-request-entity-too-large/2011/7 "2019-09-16T09:37:00Z")

</div>

Thanks Ines, I'll follow up on the custom view. Is there an option to auto-save after each single annotation? This could be the easiest patch for the current problem.

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [September 16, 2019, 10:05am UTC](https://support.prodi.gy/t/text-choice-save-error-request-entity-too-large/2011/8 "2019-09-16T10:05:10Z")

</div>

Oh yeah, I guess you could also set the `batch_size` lower, to like 1 or 2. Or set `"instant_submit": True` to send each annotation back immediately. (It does mean that you won't get to undo, though.)

---

<div class="post-metadata">

**Author:** ![nuno](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@nuno](https://support.prodi.gy/u/nuno)\
**Post date:** [September 17, 2019, 8:44am UTC](https://support.prodi.gy/t/text-choice-save-error-request-entity-too-large/2011/9 "2019-09-17T08:44:31Z")

</div>

Thanks. I can't find `instant_submit` in the README, where should I use that?

Like this? :

```
return {
    'dataset': dataset, # save annotations in this dataset
    'view_id': 'choice', # use the choice interface
    'stream': stream,
    'config': {'choice_style': 'multiple', 'show_stats': True, 'instant_submit': True},
}

```

I am running prodigy version 1.6.1

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [September 17, 2019, 9:20am UTC](https://support.prodi.gy/t/text-choice-save-error-request-entity-too-large/2011/10 "2019-09-17T09:20:18Z")

</div>

> [@nuno](#):
>
> I am running prodigy version 1.6.1

Ah, okay – the `instant_submit` is a newer feature and was added in Prodigy v1.7. See here: [Changelog · Prodigy · An annotation tool for AI, Machine Learning & NLP](https://prodi.gy/docs/changelog#1.7.0) Setting `"batch_size": 1` should be pretty similar, though, for your use case.

---

<div class="post-metadata">

**Author:** ![nuno](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@nuno](https://support.prodi.gy/u/nuno)\
**Post date:** [September 17, 2019, 9:54am UTC](https://support.prodi.gy/t/text-choice-save-error-request-entity-too-large/2011/11 "2019-09-17T09:54:35Z")

</div>

Thanks. So setting `batch_size: 1` will make Prodigy save at each 1 annotation? Is there a way to update the config file so that I don't have to add this setting to each recipe?

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [September 17, 2019, 4:17pm UTC](https://support.prodi.gy/t/text-choice-save-error-request-entity-too-large/2011/12 "2019-09-17T16:17:28Z")

</div>

Well, it will technically save after 2 annotations and then one annotation per batch (because it always keeps one annotation on the client so you can undo). But in your case, you're mostly concerned about the size of the batches sent back and forth, so this should solve the problem.

> [@nuno](#):
>
> Is there a way to update the config file so that I don't have to add this setting to each recipe?

Yes, you can also put those global settings in your `prodigy.json`.
