You can use following code to Fulfill Sales Order using JavaScript and WebApi:

var orderclose = {
        "subject": "Put Your Fulfill Subject Here",
        "salesorderid@odata.bind": "/salesorders(58D2C742-9F0D-E711-8102-3863BB354FF0)",//Put salesorder Id here
        "description": "Additional Description Here",
        "actualend": new Date()
    };

    var parameters = {
        "OrderClose": orderclose,
        "Status": -1
    };

    var context;

    if (typeof GetGlobalContext === "function") {
        context = GetGlobalContext();
    } else {
        context = Xrm.Page.context;
    }

    var req = new XMLHttpRequest();
    req.open("POST", context.getClientUrl() + "/api/data/v8.2/salesorders/Microsoft.Dynamics.CRM.FulfillSalesOrder", true);
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.onreadystatechange = function () {
        if (this.readyState === 4) {
            req.onreadystatechange = null;
            if (this.status === 204) {
                //Success - No Return Data - Do Something
            } else {
                var errorText = this.responseText;
                //Error and errorText variable contains an error - do something with it
            }
        }
    };
    req.send(JSON.stringify(parameters));

 

Запись How to Fulfill Sales Order using WebApi впервые появилась CRM Mentor.