This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice This article is not considered official documentation for K2 software and is provided “as is” with no warranties.

Issue

When we try to access to the url: on App Deployment http://{ServerName}/autodiscover/api/metadatadocument/test an error appears.

Symptoms

When adding a URL to the for K2 for Sharepoint Activation it prompts the below Error:

Endpoint cannot be reached : http://{ServerName}/autodiscover/api/metadatadocument/test

Ensure that you can browse to the endpoint from this location.

Image

Resolution

- Full K2 database backup must be taken before you start.

- Also ensure that you backup web.config file for workspace site - c:\Program Files (x86)\K2 BlackPearl\Workspace\site\web.config

Steps to repair K2 OAuth:

1. On the SharePoint Server, run the following PowerShell scripts as SharePoint Administrator

• Remove-SPTrustedSecurityTokenIssuer -Id "K2 for SharePoint"

• Remove-SPTrustedRootAuthority -Id "K2 for SharePoint"

2. Then check to see that the Providers were deleted (there should be NO K2 High Auth Certificates for K2 for SharePoint)

• Get-SPTrustedSecurityTokenIssuer

• Get-SPTrustedRootAuthority

3. Then on the SQL server where the K2 DB is, run the following:

• DELETE FROM [K2].[HostServer].[Configuration] WHERE VariableToken like '[[]K2_SIGN%' • TRUNCATE TABLE [K2].[Authorization].[OAuthAppOnlyToken]

4. Then run the following scripts to ensure it had been removed:

• SELECT * FROM [K2].[HostServer].[Configuration] WHERE VariableToken like '[[]K2_SIGN%' • SELECT * FROM [K2].[Authorization].[OAuthAppOnlyToken]

5. Next, remove the K2 Certificate from the installation folder because you will be generating a new one:

• Program Files (x86)\K2 blackpearl\Host Server\Bin\OAuth\Certificates

6. Run a K2 BlackPearl Reconfigure from installation Media (This is where you installed K2 BlackPearl from originally, remember to make a backup of the workspace config file.)

7. Check to see if a new Token and certificates were generated.

• Program Files (x86)\K2 blackpearl\Host Server\Bin\OAuth\Certificates

• SELECT * FROM [K2].[HostServer].[Configuration] WHERE VariableToken like '[[]K2_SIGN%'

• SELECT * FROM [K2].[Authorization].[OAuthAppOnlyToken]

8. On the SharePoint Server as Farm Administrator, Run the AppDeployment.exe (remember that the user you run it as, has to have rights on the K2 DB to be able to retrieve the certificate).

Next, Run the AppDeployment.exe to added the K2 For Sharepoint application. After adding in the URL of K2 the issue should be resolved and K2 for SharePoint will be added as expected.