How to create a new SPO site using REST API

Ramasubramanian, Karthik 21 Reputation points
2022-09-22T21:20:41.837+00:00

I already took a look at the "How to create a new SPO site using REST API in PowerShell", question. This is not working for me.

I am trying to provision a modern site using REST api. I am using Postman to test if this works in our test tenant. I successfully generated a bearer token using a client_id and client_secret for the test tenant. Then I try using this bearer token to then provision the site based on the example provided in the above question and answer. I am getting an error and I am unable to identify the cause of the error.

<?xml version="1.0" encoding="utf-8"?>
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code>-1, Microsoft.SharePoint.Client.InvalidClientQueryException</m:code>
<m:message xml:lang="en-US">Cannot handle the data at position 0.</m:message>
</m:error>

The attached image shows the error

244033-image.png

Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments
{count} votes

Answer accepted by question author
  1. RaytheonXie_MSFT 40,496 Reputation points Microsoft External Staff
    2022-09-23T06:51:02.107+00:00

    Hi @Ramasubramanian, Karthik ,
    Per my test, I can reproduce your issue. We can create a modern site by following api. Since the forum prevent me post the request. I will upload it by txt file. Please make a reference
    244110-rest-api.txt

    Here is the test result
    244117-image.png
    244133-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.