In SharePoint 2013 on-premises, by default, accessing the response from REST APIs in JSON format doesn’t work. We need to install WCF Data Service 5.6 to provide the support for JSON responses and will have to add the assembly references for WCF Data Services 5.6.
Check if WCFDataServices 5.6 is installed on the Web Front End Servers.
If it is not installed, download it from here.
Run the setup WCFDataServices.exe and install.
After installation, verify if the DLLs deployed for WCF Data Services are the latest (version 5.6) are installed and placed in GAC,
- Microsoft.Data.Edm
- Microsoft.Data.Odata
- Microsoft.Data.Services.Client
- Microsoft.Data.Services
- System.Spatial
Now for adding the references to these DLLs in the web service, execute the below:
- $configOwnerName = "JSONLightDependentAssembly"
- $spWebConfigModClass = "Microsoft.SharePoint.Administration.SPWebConfigModification"
- $dependentAssemblyPath = "configuration/runtime/*[local-name()='assemblyBinding' and namespace-uri()='urn:schemas-microsoft-com:asm.v1']"
- $dependentAssemblyNameStart = "*[local-name()='dependentAssembly'][*/@name='"
- $dependentAssemblyNameEnd = "'][*/@publicKeyToken='31bf3856ad364e35'][*/@culture='neutral']"
- $dependentAssemblyValueStart = "<dependentAssembly><assemblyIdentity name='"
- $dependentAssemblyValueEnd = "' publicKeyToken='31bf3856ad364e35' culture='neutral' /><bindingRedirect oldVersion='5.0.0.0' newVersion='5.6.0.0' /></dependentAssembly>"
- $edmAssemblyName = "Microsoft.Data.Edm"
- $odataAssemblyName = "Microsoft.Data.Odata"
- $dataServicesAssemblyName = "Microsoft.Data.Services"
- $dataServicesClientAssemblyName = "Microsoft.Data.Services.Client"
- $spatialAssemblyName = "System.Spatial"
- $assemblyNamesArray = $edmAssemblyName, $odataAssemblyName, $dataServicesAssemblyName, $dataServicesClientAssemblyName, $spatialAssemblyName
- if ((Get - PSSnapin - Name Microsoft.SharePoint.PowerShell - ErrorAction SilentlyContinue) - eq $null) {
- Add - PsSnapin Microsoft.SharePoint.PowerShell
- }
- $webService = [Microsoft.SharePoint.Administration.SPWebService]::ContentServic
- e################ Adds individual assemblies####################
- For($i = 0; $i - lt 5; $i++) {
- echo "Adding Assembly..."
- $assemblyNamesArray[$i]
- $dependentAssembly = New - Object $spWebConfigModClass
- $dependentAssembly.Path = $dependentAssemblyPath
- $dependentAssembly.Sequence = 0# First item to be inserted
- $dependentAssembly.Owner = $configOwnerName
- $dependentAssembly.Name = $dependentAssemblyNameStart + $assemblyNamesArray[$i] + $dependentAssemblyNameEnd
- $dependentAssembly.Type = 0# Ensure Child Node
- $dependentAssembly.Value = $dependentAssemblyValueStart + $assemblyNamesArray[$i] + $dependentAssemblyValueEnd
- $webService.WebConfigModifications.Add($dependentAssembly)
- }
- ###############################################################
- echo "Saving Web Config Modification"
- $webService.Update()
- $webService.ApplyWebConfigModifications()
- echo "Update Complete"