1

I want to pass body parameters to my post request, how to do this? In msdn article haves only example with GET request..

This is my code for get request(Its working):

    function webProxy() {
    var context = SP.ClientContext.get_current();
    var request = new SP.WebRequestInfo();
    request.set_url("http://sf-spsdev07:9810/api/Holidays/GetEventDates?siteUrl=http://sf-spsdev07/sites/Test&listName=Events");
    request.set_method("GET");
    var response = SP.WebProxy.invoke(context, request);

    context.executeQueryAsync(success, fail);

    function success() {
        if (response.get_statusCode() == 200) {
            var message = jQuery("#message");

            message.text(response.get_statusCode());
            message.append(response.get_body());

        } else {
            var errorMessage = response.get_body();
            alert(errorMessage);
        }
    }

    function fail(sender, args) {
        alert("Call failed. Error: " +
            args.get_message());
    }
}

How to do this for Post request with body paramethers?

Your Answer

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

Browse other questions tagged or ask your own question.