I’m struggling to create test users in Notion. I’ve tried both the regular API and SCIM API but keep hitting roadblocks.
With the Notion API, I’m sending a POST request to create an account. I’ve included the correct headers and JSON body with user details. But I keep getting an invalid_request_url
error.
The SCIM API is a bit better. It works if I only send the username. But when I try to add name and email info, it throws a 500 error.
Here’s a simplified version of what I’m trying:
def create_user(api_type):
if api_type == 'notion':
url = 'notion_api_endpoint'
data = {
'name': 'John Doe',
'email': '[email protected]'
}
else:
url = 'notion_scim_endpoint'
data = {
'userName': '[email protected]',
'givenName': 'John',
'familyName': 'Doe'
}
response = requests.post(url, json=data, headers=headers)
return response.json()
# Both calls fail
print(create_user('notion'))
print(create_user('scim'))
Any ideas what I’m doing wrong? I just want to create a user with a name and email.
I’ve encountered similar issues with Notion’s API and SCIM implementation. From my experience, the invalid_request_url error often occurs due to an incorrect endpoint URL or when the proper API version is not included in the headers. It’s crucial to verify both the URL and the API version, such as using 2022-06-28 if required.
Regarding the SCIM API and the 500 error, this typically indicates a server-side problem. Streamline your request by sending only the simplest valid payload for the required fields, ensuring that all values are strings. Also, confirm that the authorization token you are using has sufficient permissions for creating new users.
If these steps fail, it might be best to contact Notion’s support for more tailored assistance.
I’ve been down this road with Notion’s API, and it can be frustrating. For the regular API, make sure you’re using the correct base URL (https://api.notion.com/v1/) and appending the right endpoint. Also, check that your Integration Token has the necessary permissions.
As for SCIM, I’ve found it to be quite temperamental. Try this approach: start with just the userName, then gradually add other fields one by one, testing each time. This way, you can pinpoint which field is causing the 500 error.
Here’s a snippet that’s worked for me with SCIM:
data = {
'schemas': ['urn:ietf:params:scim:schemas:core:2.0:User'],
'userName': '[email protected]',
'name': {
'givenName': 'John',
'familyName': 'Doe'
},
'emails': [{'value': '[email protected]', 'primary': True}]
}
If all else fails, Notion’s developer documentation can be a lifesaver. Good luck!
yo, ive run into this crap before. notions api can be a real pain. make sure ur using the right endpoint url - double check that. for scim, try stripping down ur payload to just the bare minimum. sometimes less is more with these finicky apis. if ur still stuck, hit up notion support. they might be able to sort u out.