Forum Discussion
MS Forms API implementation
Well, just in case you are still interested in how to delete responses from an specific user, here is an approach that I tried and it's working for me.
First of all, you need to understand the structure of the Forms API.
https://forms.office.com/formapi/api/[TenantID]/users/[UserID]/forms('[FormID]')/responses
[TenantID] - no doubts about it, tenant ID where the form is hosted.
[UserID] - is the UserID of the Form owner.
[FormID] - no doubts about this.
If you try this API and take a look to the JSON, you will see each response has an ID.
To delete a single ID, you just need to use the delete method specifying the response ID.
https://forms.office.com/formapi/api/[TenantID]/users/[UserID]/forms('[FormID]')/responses([ResponseID])
But if you need to delete all responses from specific user, you may use the first API call to collect all responses, parse the JSON, filter the array by responder property. Just note the responder property uses the responder UPN, not the email.
Now you have an array with the responder UPN and the response ID, just use an apply to each loop to delete each response.
is this still working for you. I've had this working for a few weeks now and all of a sudden querying for individual responses seems to not respond.
Trying to find out if it is just me or something larger going on.
- samb2180Sep 19, 2024Brass Contributor
Hi jimbanach-msft,
Nope, it just stopped working. My workaround is to read the excel file associated to the form. This is only possible when the form is created within a Teams group.
When you create the form in a Teams group, an excel file is created in the General library. If you create the form in other channel than General, the excel file will be created in the library of the channel.
Once located, you can use the list rows present in a table action to get the total number of answers. That's your rdix number.