How to update options of a multichoice questions' in a form, via API | Community
Skip to main content
Question

How to update options of a multichoice questions' in a form, via API

  • August 13, 2024
  • 7 replies
  • 101 views

I am currently adding integrations for different typeform events (triggers & actions) to our platform. I am unable to find the correct API syntax for the event - “Update Dropdown, Multiple Choice or Ranking Question Options

 

I am trying to update the options of a multi-choice question via API. Here is the Api details and error message i am getting:

 

API Endpoint - https://api.typeform.com/forms/:formId

Method - PATCH

 

Body used - 

[
    {
        "op": "replace",
        "path": "/fields",
        "value": [
            {
                "id": "Multichoice_Question/Field_id",
                "properties":{
                    "choices": [
                        { "label": "Red" },
                        { "label": "Green" },
                        { "label": "Blue" }
                    ]
                }
            }
        ]
    }
]

 

error message - 

{
    "code": "VALIDATION_ERROR",
    "description": "The payload is invalid.",
    "details": [
        {
            "code": "NOT_ALLOWED_VALUE",
            "description": "should be equal to one of the allowed values",
            "field": "/0/path",
            "in": "body"
        }
    ]
}

 

How should the body be defined for this API?
I can see that api doc defines certain fixed values which "path" can take. But then how are we supposed to update a multi-choice questions' options using this API?

7 replies

Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 14840 replies
  • August 13, 2024

Hi @nikko Happy Tuesday!

@picsoung or @mathio do either of you happen to know the answer to this? 


mathio-tf
Typeform
Forum|alt.badge.img+5
  • Typeform
  • 888 replies
  • August 14, 2024

Hello @nikko 

I dont think you can update a field via PATCH endpoint. You will need to use PUT endpoint instead. You will need to GET full form definition, and then send it to the PUT endpoint with changed values.


picsoung
Typeform
Forum|alt.badge.img+5
  • Developer Advocate @ Typeform
  • 384 replies
  • August 15, 2024

Just confirming what @mathio mentioned.

The PATCH endpoint can only modify form settings.
If you want to modify anything about the form, you must manipulate the whole definition.

First, by getting the latest version calling GET /forms/{form_id} doc
You can get the JSON and then do the modification you want.
Once you are ready, push it back to Typeform by calling PUT /forms/{form_id} doc

You can update the form as many times as you want. Consider a list of choices, like classes or availability from another system. Or if you want to remove the choice after it has been selected X many times.


  • Author
  • Explorer
  • 1 reply
  • August 15, 2024

Hello everyone!

Thankyou for your quick replies. Will try it out.

Thanks again! 😊 

 


Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 14840 replies
  • August 22, 2024

Let us know how it went, @nikko !


  • Navigating the Land
  • 1 reply
  • February 3, 2025

TBH you have one of the worst REST APIs I have to work with.
Developers hate you, any tech-savvy people hate you.

This feature is asked for years, how the heck can’t you provide a “form field” API so we can update multichoice questions options in 1 single HTTP call ?

 

You cost me an full time day of work to allow my team trigger the update of a single field.
A day.


Liz
Community Team
Forum|alt.badge.img+5
  • Tech Community Advocate
  • 14840 replies
  • February 6, 2025

Hi ​@article1data Thanks for stopping by and sharing this. I can certainly pass along this request to our product team!


Reply