0

I want to create a simple webpage with a form that can create new items in a SharePoint list. I want to make this as a remote site that just connects to sharepoint.

Since I had a problem with REST API (it returned a 403 Forbidden exception), I decided to use SPServices to do it. When running this script:

var itemProperties = [["Title", $("#surname").val()], ["Data", $(".js-my-date").val()]];

$().SPServices({
    operation: "UpdateListItems",
    async: false,
    batchCmd: "New",
    webURL: 'https://mysite.sharepoint.com/sites/me/',
    listName: 'ListNrOne',
    valuepairs: itemProperties,
    completefunc: function(xData, Status) {
        if (xData.status === 200 && xData.statusText === "OK") { 
            $('#result').text("Row created with ID: " + $(xData.responseXML).SPFilterNode("z:row").attr("ows_ID") );
        } else {
            $('#result').text("It did not went well");
        }
    }
});

...I get 405 Method Not Allowed.

I tried it once inside an aspx file which I kept inside the SharePoint folder structure (it worked).

Now I'm trying from an html file uploaded to a remote site. I get 405 Method Not Allowed.

What is the problem? I have a hunch that it's all about priviliges or credentials, but I have no idea how to deal with it. Can anyone help me?

1 Answer 1

3

You're running into cross-site scripting errors. This has nothing to do with SPServices, but is a security thing in browsers and servers. The basic idea is that a page coming from some random place shouldn't be able to run script that writes to a different domain. If you think about it, that's a good thing, as it keeps all our interfaces secure. Yet at the same time, it's really annoying when you want to get around it!

0

Your Answer

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

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