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,

  1. Microsoft.Data.Edm
  2. Microsoft.Data.Odata
  3. Microsoft.Data.Services.Client
  4. Microsoft.Data.Services
  5. System.Spatial

Now for adding the references to these DLLs in the web service, execute the below:

  1. $configOwnerName = "JSONLightDependentAssembly"
  2. $spWebConfigModClass = "Microsoft.SharePoint.Administration.SPWebConfigModification"
  3. $dependentAssemblyPath = "configuration/runtime/*[local-name()='assemblyBinding' and namespace-uri()='urn:schemas-microsoft-com:asm.v1']"
  4. $dependentAssemblyNameStart = "*[local-name()='dependentAssembly'][*/@name='"
  5. $dependentAssemblyNameEnd = "'][*/@publicKeyToken='31bf3856ad364e35'][*/@culture='neutral']"
  6. $dependentAssemblyValueStart = "<dependentAssembly><assemblyIdentity name='"
  7. $dependentAssemblyValueEnd = "' publicKeyToken='31bf3856ad364e35' culture='neutral' /><bindingRedirect oldVersion='5.0.0.0' newVersion='5.6.0.0' /></dependentAssembly>"
  8. $edmAssemblyName = "Microsoft.Data.Edm"
  9. $odataAssemblyName = "Microsoft.Data.Odata"
  10. $dataServicesAssemblyName = "Microsoft.Data.Services"
  11. $dataServicesClientAssemblyName = "Microsoft.Data.Services.Client"
  12. $spatialAssemblyName = "System.Spatial"
  13. $assemblyNamesArray = $edmAssemblyName, $odataAssemblyName, $dataServicesAssemblyName, $dataServicesClientAssemblyName, $spatialAssemblyName
  14. if ((Get - PSSnapin - Name Microsoft.SharePoint.PowerShell - ErrorAction SilentlyContinue) - eq $null) {
  15. Add - PsSnapin Microsoft.SharePoint.PowerShell
  16. }
  17. $webService = [Microsoft.SharePoint.Administration.SPWebService]::ContentServic
  18. e################ Adds individual assemblies####################
  19. For($i = 0; $i - lt 5; $i++) {
  20. echo "Adding Assembly..."
  21. $assemblyNamesArray[$i]
  22. $dependentAssembly = New - Object $spWebConfigModClass
  23. $dependentAssembly.Path = $dependentAssemblyPath
  24. $dependentAssembly.Sequence = 0# First item to be inserted
  25. $dependentAssembly.Owner = $configOwnerName
  26. $dependentAssembly.Name = $dependentAssemblyNameStart + $assemblyNamesArray[$i] + $dependentAssemblyNameEnd
  27. $dependentAssembly.Type = 0# Ensure Child Node
  28. $dependentAssembly.Value = $dependentAssemblyValueStart + $assemblyNamesArray[$i] + $dependentAssemblyValueEnd
  29. $webService.WebConfigModifications.Add($dependentAssembly)
  30. }
  31. ###############################################################
  32. echo "Saving Web Config Modification"
  33. $webService.Update()
  34. $webService.ApplyWebConfigModifications()
  35. echo "Update Complete"