Approve workflow tasks using REST API in SharePoint 2013

Recently I had a requirement to approve a workflow task programmatically. I found some useful posts here and here but they were related to SharePoint 2010 and the code did not work with SharePoint 2013 as it is.

After doing some modifications the below code worked fine and the workflow moved ahead after the task was approved.

//Some times outcome field's internal name could be different
//Go to list settings of your Workflow Tasks to verify the internal names of all the fields below
var item = {
	"__metadata": { "type": "SP.Data.Workflow_x0020_TasksListItem" },
	"WorkflowOutcome" : "Approved",
	"Status" : "Approved",
	"PercentComplete" : 1,
	"Checkmark" : "Yes"
};

//URL here is the direct uri to the item which can be obtained by doing a GET request for the item and reading data.__metadata.uri from the response
$.ajax({
	url: "http://yoursite/PG/_api/Web/Lists(guid'3c871781-7c22-4bd2-8b2c-310babe69ccd')/Items(3)",
	type: "POST",
	contentType: "application/json;odata=verbose",
	data: JSON.stringify(item),
	headers: {
		"Accept": "application/json;odata=verbose",
		"X-RequestDigest": $("#__REQUESTDIGEST").val(),
		"X-HTTP-Method": "MERGE",
		"If-Match": "*"
	},
	success: function (data) {
		debugger;
	},
	error: function (data) {
		debugger;
	}
});

“The Subscription Settings service and corresponding application and proxy needs to be running in order to make changes to these settings” – even after configuring subscription Settings Service

I completed configuring my SharePoint 2013 box yesterday and with at most curiosity of creating my first app I opened Visual Studio 2012 and create a SharePoint hosted app. And I was greeted with my first error message on SharePoint 2013.

Apps are disabled on the site‘.

I then learnt that the ‘App Management Service’ and the ‘Microsoft SharePoint Foundation Subscription Settings Service’ should be up and running before I can configure the App URLs in Central Administration and deploying apps.

(Note: You must create a separate app domain for deploying your apps before all these which I have done already following this article)

The former is created automatically while installing SP 2013 but to get the later running we have to do it manually by creating a service application. This can be done through the powershell –

add-pssnapin </code><code>"Microsoft.Sharepoint.Powershell"
$manaccount = Get-SPManagedAccount nlv\Administrator
Remove-SPServiceApplicationPool -Identity SettingsServiceAppPool
$appPoolService = New-SPServiceApplicationPool -Name SettingsServiceAppPool -Account $manaccount
$appService = New-SPSubscriptionSettingsServiceApplication -ApplicationPool $appPoolService -Name SettingsServiceApp -DatabaseName SettingsServiceDB
$proxyService = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $appService
So now I see that both the services are up and running.
Image

So again I navigated to Apps -> Configure Apps URLs in CA and again daang! Same message –

‘The Subscription Settings service and corresponding application and proxy needs to be running in order to make changes to these settings’

I was googling for an hour and found everywhere that only these two service applications have to be started to configure app URLs. And finally I found the silly step which has to be done after creating subscription settings service application given by chaks here.

You have to do an IISRESET and bingo! Now you will able to configure App URLs in CA.

Image