I created a list from appweb to hostweb and the list url is without "lists/" I then trying to use ajax call post on my startsite (not from the app) but i get following error: 400 bad request x.support.cors.e.crossDomain.send

SharePoint Online

   function saveSelectedAnswer(selectedAnswer) {
        var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('PollUserData')/items/";
        var pollData = {
            __metadata: {
                "type": "SP.Data.PollUserDataListItem"
            Title: 'test',
            UserID: userGuid, //text
            Question: allQuestionsArray[0].Question, //text
            QuestionAnswers: allQuestionsArray[0].Answers, //text
            Answer: selectedAnswer,  //text
            QuestionID: allQuestionsArray[0].ID //number
                //Check field types if error
        var requestBody = JSON.stringify(pollData);
        var requestHeaders = {
            "ACCEPT": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),
            url: requestUri,
            type: "Post",
            async: false,
            contentType: "application/json;odata=verbose",
            data: requestBody,
            headers: requestHeaders,
            success: function() {
                console.log("data saved");
            error: function(xhr, thrownError) {
                alert("Error save answers " + xhr.status + " " + thrownError);

1 Answer 1


OK, i came up with a solution by myself. The fix was to set url to Lists/'name of your list'. That did the work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.