Register-SPWorkflowService Failed to query the OAuth S2s metadata error

Scenario: You have followed all the specified TechNet requirements/permissions in setting up SharePoint 2013 and Workflow Manager 1.o farm but when Registering Workflow manager with SharePoint site collection you might have got the below error:

Register-SPWorkflowService : Failed to query the OAuth S2S metadata endpoint at URI ‘http://xxxx/_layouts/15/metadata/json/1’. Error details: ‘An error occurred while sending the request.’. HTTP headers received from the server – ActivityId: 5b035802-7a59-4235-acb5-943a0e21e942. NodeId:
xxxx. Scope: /SharePoint. Client ActivityId : 66bd6434-9778-4a6f-b275-63a399d73c8c.
At line:1 char:1 + Register-SPWorkflowService -SPSite “http://xxxx” -WorkflowHostUri
“http …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
    + CategoryInfo          : InvalidData: (Microsoft.Share…WorkflowService:
   RegisterSPWorkflowService) [Register-SPWorkflowService], InvalidRequestExc
  eption
    + FullyQualifiedErrorId : Microsoft.SharePoint.WorkflowServices.PowerShell
   .RegisterSPWorkflowService

WFerror1

Solution:

When looking at the SharePoint logs – the error details are

Microsoft.Workflow.Client.InvalidRequestException: Failed to query the OAuth S2S metadata endpoint at URI ‘http://xxxx/_layouts/15/metadata/json/1’. Error details: ‘An error occurred while sending the request.’. HTTP headers received from the server – ActivityId: 1b2624e2-42a0-4a93-8c93-2ada0630967c. NodeId: xxxx. Scope: /SharePoint. Client ActivityId : 487d86fd-c961-4d8c-aab2-47269989b292. —> System.Net.WebException: The remote server returned an error: (400) Bad Request.     at Microsoft.Workflow.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)     at Microsoft.Workflow.Client.HttpGetResponseAsyncResult`1.End(IAsyncResult result)     at Microsoft.Workflow.Client.ClientHelpers.SendRequest[T](HttpWebRequest request, T content)     — End of inner exception stack trace —     at Microsoft.Workflow.Client.ClientHelpers.SendRequest[T](HttpWebRequest request, T content)     at Microsoft.Workflow.Client.WorkflowManagementClient.SendRequest[T](HttpWebRequest request, T content)     at Microsoft.Workflow.Client.ScopeManager.PublishScopeInternal(ScopeDescription description, String[] pathSegments)     at Microsoft.SharePoint.WorkflowServices.WorkflowServerPairingContext.EnsureFarmScope(Boolean configureOAuth)     at Microsoft.SharePoint.WorkflowServices.PowerShell.RegisterSPWorkflowService.InternalProcessRecord()     at Microsoft.SharePoint.PowerShell.SPCmdlet.ProcessRecord()

Basically it is trying to connect to the SharePoint url end point (http://xxxx/_layouts/15/metadata/json/1 . In my case the SharePoint url (which has host header) was not accessible from Workflow Manager server (as I have not dns published the url). I added the SharePoint url to the Workflow manager server host file and can access the SharePoint url.

Now the Register-SPWorkflowservice command runs without issue.

Key here is that make sure that both SharePoint and workflowhost urls are accessible from the SharePoint / Workflow Manager server.

Hope this helps :-).

Advertisements

One Response to Register-SPWorkflowService Failed to query the OAuth S2s metadata error

  1. hugheser says:

    THANK YOU! I was building a workflow farm before DNS had updated. I added the URL to the local hosts file and it works.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: