Categories
Microsoft

Microsoft Graph API – Invalid hostname error

This is just a little tip for the future myself (or someone falling the same issue).

Microsoft Graph is a GraphQL Gateway to resources related to Microsoft 365 (including Drive, Sharepoint, and many others).

After some environment updates, I started to receive an error when using an endpoint with SITE ID path:

{
	"error": {
		"code": "invalidRequest",
		"message": "Invalid hostname for this tenancy",
		"innerError": {
			"date": "2024-04-16T14:36:10",
			"request-id": "8a38f260-332f-4463-b59e-0127c31987b2",
			"client-request-id": "8a38f260-332f-4463-b59e-0127c31987b2"
		}
	}
}

The message was confusing because I didn’t change any endpoint host. Tried to search for the error and found wrong answers only.

If you have the same issue, do a double check at the SITE ID value in your path, that’s the problem.

Example: https://graph.microsoft.com/v1.0/sites/SITE ID/drive/root

That’s all folks.

You don’t need to use the triple ID (the original response "YOUR_TENANT.sharepoint.com,YOUR_SITE_ID,YOUR_WEB_ID" as the SITE_ID). Or any other change.