Because of the limitations of SP Designer URL's I've had to create a custom webservice to Publish, Checkin, Approve etc.... I pass the List ID and a comment as parms in the HTTP POST. The WCF lives in the /15 ISAPI directory as it should.
I setup 3 dictionaries:
POST_RequestHeader
content-type: application/json;odata=verbose, accept:application/json;odata=verbose, X-HTTP-Method: MERGE, IF-MATCH:*,Authorization:
If I don't include Authorization as null, I get a 401. With this I get a 403.
POST_Metadata
type string "name of my SP.Data category from tyhe list"
POST_Parameters
__metadata with the name of POST_Metadata
Call the webservice in SP DESIGNER 2013
RequestHeaders set to POST_RequestHeader
RequestContent set to POST_Parameters
The Interface correctly maps and routes me to the method. The document is in Draft state ready for "Publish a Major version".
I cannot get past the security errors. My GET methods work fine. Any thoughts? How can I pass the proper credentials?
I'm running in an App Step and have granted workflows elevated privileges so no problem there.
Thanks.
using (SPSite siteCollection = new SPSite("myservercollectionurl"))
{
using (SPWeb web = siteCollection.OpenWeb())
{
SPWeb site = siteCollection.RootWeb;
SPList corpPol = site.Lists["Our Policies"];
SPListItem spListItem = corpPol.GetItemById(id);
SPFile file = spListItem.File;
trace = "In SPsite Loop" + spListItem["Title"].ToString(); <--- Title is written OK to log
diagSvc.WriteTrace(0, category, TraceSeverity.Verbose, trace);
if (file.CheckOutType == SPFile.SPCheckOutType.None)
{
spListItem.File.Publish("done in WCF"); <-- Blows everytime with 403 Forbidden
}
This is in the Sharepoint logs:
System.Runtime.InteropServices.COMException (0x8102006D): The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again. at Microsoft.SharePoint.SPFile.PublishOrUnPublish(String comment, Boolean fPublish)
Tom