Monthly Archives: November 2018

FIXED – Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0

When coding JavaScript with SP-PNP-JS I came across the error below and wanted to document for others.  Cheers!  shades_smile

Error

Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0

image

image

image

Root Cause

When calling HTTP GET the default Header “accept: application/json” can return data as XML.  

Use F12 Developer Tools to view network traffic with HTTP headers and raw response text.

Solution

Modify JS code to initialize AngularJS with different HTTP headers.

Now SharePoint PNP api calls with Header “accept: application/json; odata=verbose” and returns data as JSON for correct parsing.

$pnp.setup({
	headers: {
		"Accept": "application/json; odata=verbose"
	}
});

image

References

What’s in that patch? Nov 2018

NOTE – PDF format updated to include both SharePoint 2013 and 2016 notes.

Ever wondered what fixes are inside of a given CU?   Please see attached PDF with full detail. I wanted a new format for easy reading.   Show management and make the business case for why downtime should be taken to apply CUs.  Also posted at https://sharepointupdates.com/

If you found this helpful, please leave a comment.    shades_smile_thumb_thumb_thumb_thumb[2]

Download

What’s in that patch – Nov 2018.PDF

FIXED – Distributed Cache is Unhappy

When SharePoint Server Distributed Cache is unhappy in a farm, you may see page loads error, 404s not found, API failures, and similar.   Having a well configured Distributed Cache will ensure healthy page renderings.  PowerShell notes below. Credit to one awesome long term SP engineer for the snippets below. Thank you.   Cheers!  shades_smile

Image result for sharepoint distributed cache


CHECK STATUS

To check the status of the Distributed Cache Servers, run this command on each Farm from a DC machine.

# CHECK DC STATUS
Use-CacheCluster;
Get-CacheHost;
$servers=Get-CacheHost;
foreach ($server in $servers) {
  Get-AFCacheHostConfiguration -ComputerName $server.hostname -CachePort "22233"
}

REMOVE SERVER

# REMOVE COMPUTER TO DC HOSTS
Remove-SPDistributedCacheServiceInstance

ADD SERVER

# ADD COMPUTER TO DC HOSTS
Add-SPDistributedCacheServiceInstance

CHANGE SERVICE = UP

To change the Service Status of a server to UP, run these commands on the server you wish to bring UP.

# CHANGE DC STATUS = UP
$instanceName ="SPDistributedCacheService Name=AppFabricCachingService"
$serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName -and ($_.server.name) -eq $env:computername}
$serviceInstance.Provision()

CHANGE STATUS = DOWN

To change the Service Status of a server to DOWN, run these commands on the server you wish to bring DOWN.

# CHANGE DC STATUS = DOWN
$instanceName = "SPDistributedCacheService Name=AppFabricCachingService"
$serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName -and ($_.server.name) -eq $env:computername}
$serviceInstance.Unprovision()

CHANGE IsLeadHost=FALSE

There can be only one IsLeadHost=True server in a Farm.  If there is more than is IsLeadHost=True servers your Farm will act unstable and people will see page load errors. We traditional set the lowest server name alphabetically in a Farm as IsLeadHost.  Change the DC Farm so that Service Status=DOWN on server.

# CHANGE LEAD HOST = FALSE
Use-CacheCluster;
$instanceName = "SPDistributedCacheService Name=AppFabricCachingService"
$serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName -and ($_.server.name) -eq $env:computername}
$serviceInstance.Unprovision()
#Change IsLeadHost value to false (use computer name or local computer name)
Set-CacheHostConfig -HostName $env:computername -CachePort 22233 -IsLeadHost "false" -RefreshNow
# CHANGE DC SERVER STATUS = UP
$instanceName ="SPDistributedCacheService Name=AppFabricCachingService"
$serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName -and ($_.server.name) -eq $env:computername}
$serviceInstance.Provision()
# WAIT 30 SECONDS FOR DC STATUS=UP
Start-Sleep -s 30
# CHECK DC STATUS
Use-CacheCluster; Get-CacheHost; $servers=Get-CacheHost;
foreach ($server in $servers) {
Get-AFCacheHostConfiguration -ComputerName $server.hostname -CachePort "22233"
}

More than one IsLeadHost=True is BAD.

SET DC CACHE SIZE (24GB server = 6GB CACHE)

Also notice our default DC cache size is only 819 MB.  MSFT formula = 24GB-2GB=22GB/2GB=11GB. Typical recommendation for a 24GB server is no more than 8GB Cache size. If running 24GB RAM on WFE, we should allocate 6GB (1024*6=6144 MB).

# CHANGE DC  STATUS = DOWN
$instanceName = "SPDistributedCacheService Name=AppFabricCachingService"
$serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName -and ($_.server.name) -eq $env:computername}
$serviceInstance.Unprovision()
# CHANGE DC CACHE SIZE (6GB)
Update-SPDistributedCacheSize -CacheSizeInMB 6144
# CHANGE DC SERVER STATUS = UP
$instanceName ="SPDistributedCacheService Name=AppFabricCachingService"
$serviceInstance = Get-SPServiceInstance | ? {($_.service.tostring()) -eq $instanceName -and ($_.server.name) -eq $env:computername}
$serviceInstance.Provision()

References

Return to Top ▲Return to Top ▲