0

I am working on SharePoint hosted app. I am facing an error in the beginning of the app i.e. "Invalid field or parameter requestInfo.url." This error is came from bellow code:

function execOperation() {
    try {
        debugger;
        context = new SP.ClientContext(hostweburl);
        var factory =
            new SP.ProxyWebRequestExecutorFactory(
                appweburl
            );
        context.set_webRequestExecutorFactory(factory);
        appContextSite = new SP.AppContextSite(context, hostweburl);
        web = appContextSite.get_web();
        context.load(web);
        taxonomyList = web.get_lists().getByTitle("Test");

        //From this line I am getting error...
        context.executeQueryAsync(onSuccess, onFail);
    }
    catch (err) {
        alert(err.message);
    }
}

If I put braces on the methods like :

context.executeQueryAsync(onSuccess(), onFail());

Then it does not give any error but it executes both the functions. What is the reason behind this.

I have also tried:

context.executeQueryAsync(Function.createDelegate(this, onSuccess), Function.createDelegate(this, onFail));

This also gives me error. How can I solve this? Can anyone help me to solve this? Thank you in advance...!

1

I think you got this error because your current SP context is on app web. So, when you create new context with hostweburl, it will be an error. You should try to use this:

Replace:

context = new SP.ClientContext(hostweburl);

By:

context = new SP.ClientContext();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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