wphead
1
API_KEY=xxx
ENDPOINT=“https://mymainwpinstall.com/wp-json/mainwp/v2/add/?url=https://somedomain.com&admin=admin%20name&name=somedomain.com”
response=$(curl -s -X PUT “${ENDPOINT}” -H “Authorization: Bearer ${API_KEY}”)
response is:
{“code”:“rest_no_route”,“message”:“No route was found matching the URL and request method.”,“data”:{“status”:404}}
How can I add a site with the v2 API?
does anyone have an example curl command to do it?
bojan
(Bojan Katusic)
2
Hey @wphead
Welcome to the MainWP community!
Seems like you’re missing /sites/
after /v2/
in your endpoint.
This is the correct endpoint:
{{mainwp-dashboard-url}}/wp-json/mainwp/v2/sites/add/?url={{site_URL}}&name={{site_name}}&admin={{admin_username}}
You can find all endpoints and example calls in our Postman.
wphead
3
Thanks Bojan, I added that, and get the same error. It works for you?
bojan
(Bojan Katusic)
4
Thanks for the update.
Yes, it indeed does work for me. In this response example, you can see that a child site was added using that API call.
Would you mind opening a private Help Desk ticket so we can collect some additional information & investigate further?
And please refer to this Managers thread by its URL in the ticket.
wphead
5
thanks,
I get
Couldn’t access this workspace
You don’t have permission to access this workspace.
when trying to view your postman link.
i’ll open a ticket shortly.
1 Like
bojan
(Bojan Katusic)
6
Just to provide an update on this -
We have changed the /sites/add/
call from allowing POST, PUT, PATCH
to only allowing POST
method.
We have now updated the Postman documentation and the respective example call to reflect this change.
system
(system)
Closed
7
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.