Check In file with Javascript and REST

I am trying to check in a file from my sharepoint-hosted app with jsom and rest, but it wont work

my code look like this:

function checkInFile() {

    var hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
    currentContext = new SP.ClientContext.get_current();
    var hostContext = new SP.AppContextSite(currentContext, hostUrl);
    hostweb = hostContext.get_web();


        url: appWebUrl + "/_api/SP.AppContextSite(@target)/web/getfilebyserverrelativeurl('/style library/popup.js')/checkin(comment='Check-in comment.',checkintype=0)[email protected]="+ hostWebUrl + "",
        method; "POST", 
        success; successHandler,
        error; errorHandler

         function successHandler() {
              $('#message').append('<br /> <div>File sucessfully checked-in</div>')
           function errorHandler(sender, args) {
             $('#message').append('<br /><div>Error: Status file not check-in</div>');

SharePoint Asked by Anders on December 19, 2020

1 Answers

One Answer

You can access the host web to check in the file using REST with the cross domain javascript library as mentioned in this article link. You need to execute the query on the RequestExecutor.

Answered by Vipul Kelkar on December 19, 2020

Add your own answers!

Related Questions

Like the List created and not the list item

2  Asked on January 27, 2021 by antra-sharma


SP 2016 – Only TTFB slow

2  Asked on January 16, 2021 by mhouston100


Unable to upload to SharePoint Online via VBA

1  Asked on January 11, 2021 by leroy


How to Create WF with C#

2  Asked on January 8, 2021 by whatsup


Ask a Question

Get help from others!

© 2022 All rights reserved.