I'm trying to figuring out the API and I've got some problems. How do I change questions in the form? I mean remove / rearrange.
I think this endpoint should do that: https://api.videoask.com/forms/{{form_id}} and I can see that it's being called when I change form from VideoAsk app. But I'm not sure how to do it (what parameters should be passed). So let's assume I have form with questions:
[1, 2, 3]
If I want to change it to be:
[3, 2]
What request should I make?
Best answer by andrew_videoask
Hi @Timur!
This is definitely a more advanced use case, but it’s certainly possible to achieve.
I’ve included some working Python code below for you to use as a reference point.
I’ll also include screenshots of the original videoask and the end result (after the logic transformations have been applied via API).
# Set headers for API calls headers = { "authorization": f"Bearer {api_token}", "organization-id": organization_id }
# Delete blue step response = requests.request("DELETE", f"https://api.videoask.com/questions/{blue_question_id}", headers=headers) print(response.text)
# Connect red step to end screen response = requests.request("PATCH", f"https://api.videoask.com/questions/{red_question_id}", headers=headers, json={"logic_actions":[{"action":"jump","details":{"to":{"type":"goodbye","value":"default"}},"condition":{"op":"always","vars":[]}}]}) print(response.text)
# Connect yellow step to red step response = requests.request("PATCH", f"https://api.videoask.com/questions/{yellow_question_id}", headers=headers, json={"logic_actions":[{"action":"jump","details":{"to":{"type":"question","value":f"{red_question_id}"}},"condition":{"op":"always","vars":[]}}]}) print(response.text)
# Set headers for API calls headers = { "authorization": f"Bearer {api_token}", "organization-id": organization_id }
# Delete blue step response = requests.request("DELETE", f"https://api.videoask.com/questions/{blue_question_id}", headers=headers) print(response.text)
# Connect red step to end screen response = requests.request("PATCH", f"https://api.videoask.com/questions/{red_question_id}", headers=headers, json={"logic_actions":[{"action":"jump","details":{"to":{"type":"goodbye","value":"default"}},"condition":{"op":"always","vars":[]}}]}) print(response.text)
# Connect yellow step to red step response = requests.request("PATCH", f"https://api.videoask.com/questions/{yellow_question_id}", headers=headers, json={"logic_actions":[{"action":"jump","details":{"to":{"type":"question","value":f"{red_question_id}"}},"condition":{"op":"always","vars":[]}}]}) print(response.text)
Hi @andrew_videoask! Huge thanks – it is working now!
Although I think there are some rate-limits to DELETE question request? I’m getting ‘internal server error’ when trying to delete more than 2 question in parallel. Not a problem for me – just curious
Also, when creating form through API I’m passing:
metadata: { locale: 'en-US' }
in body – because app is throwing a error in other case (after ~5 seconds upon form opened)