facebookapifacebook-workplace

Facebook Workplace Account Management API - Update user


I have a workplace application,
I wish to change emailIds of the user via API,
I found that Account Management API can be used to modify user details via API calls.

My use-case is to modify user email via the Account Management API, which comes under urn:scim:schemas:core:1.0 schema extension,
I wish to overwrite the existing email with the one I would specify in the requestBody,
From the documentation, I've come up with the following request -

Url endpoint -
https://someCompanyName.facebook.com/scim/v1/Users/ HTTP/1.1

Method type -
POST

Request body-

{
    "schemas": [
        "urn:scim:schemas:core:1.0",
        "urn:scim:schemas:extension:facebook:auth_method:1.0"
    ],
    "userName": "abc",
    "name": {
        "formatted": "Julius Caesar"
    },
    "emails": ["abc@gmail.com"],
    "urn:scim:schemas:extension:facebook:auth_method:1.0": {
        "auth_method": "password"
    }
}

Is it correct? What modifications do I need to make to the request?


Solution

  • in order to change the emails of a user you have to do a PUT request to the address https://www.facebook.com/scim/v1/Users/{userId}

    and you have to change in your payload the email address:

    {
        "schemas": [
            "urn:scim:schemas:core:1.0",
            "urn:scim:schemas:extension:facebook:auth_method:1.0"
        ],
        "userName": "abc",
        "name": {
            "formatted": "Julius Caesar"
        },
        "emails": [
            {
                "primary": true,
                "type": "work",
                "value": "newemail@gmail.com"
            }
        ],
        "urn:scim:schemas:extension:facebook:auth_method:1.0": {
            "auth_method": "password"
        }
    }
    

    Hope it helps