Open dhiru08484 opened 6 years ago
I think its caused by SPSurveyService.getListName function. It gets the Title of the survey list and passes its result to SPSurveyService.getItemTypeForListName which produces ListItemEntityTypeFullName of the target survey list. You add that 'ListItemEntityTypeFullName' to item metadata in postVote function. You can NOT post votes because that property is built incorrectly. Thats the story.
Exact problem with getListName was that it assumed it was processing XML and in my case my rest endpoint was returning JSON.
To solve that problem in a more elegant way, I have created another function to fetch ListItemEntityTypeFullName from rest api and replaced that with getListName & getItemTypeForListName in postVote function.
You could fetch that property like this: https://yourtenant.sharepoint.com/_api/Web/Lists(guid'b1893655-f211-44d1-b243-fa8b93bb2a23')?$select=ListItemEntityTypeFullName
Becareful if you have special characters in your survey title it may return xml even though you set application/json in your request header.
Also in case of your questions in the survey list have some special characters, I humbly advise you to pass questionInternalName instead of question title to postVote function.
edit: you can also use pnpjs to get ListItemEntityTypeFullName property.
Thank you So much for your advice. I will try your suggestions and let you know the results.
This worked for me.
public postVote(surveyListId: string, question: string, choice: string): Promise
});
}) as Promise
private getItemTypeForListName(listId: string): Promise
return responseFormated.ListItemEntityTypeFullName;
});
});
//return "SP.Data." + name.charAt(0).toUpperCase() + name.split(" ").join("").slice(1) + "ListItem";
}
simple poll is not submitting the data to survey list . Please let us know if i need to change anything on code.