const data = new URLSearchParams();
const accessToken = `<ACCESS TOKEN>`
data.append('firstname', 'Testfirstname');
data.append('lastname', 'Testlastname');
data.append('job_title', 'Job title');
data.append('email', '[email protected]');
data.append('company', 'Testcompany');
data.append('department', 'Testdepartment');
data.append('phone_number', 'Testphone');
data.append('phone_number_extension', 'Testext');
data.append('location_city', 'Testcity');
data.append('location_state', 'ON');
data.append('location_country', 'CA');
data.append('location_postal', 'Testpostal');
data.append('location_address', 'Testaddress');
data.append('location_building', 'Testbuilding');
data.append('location_room', 'Testroom');
data.append('is_published', '1');
data.append('is_private', '0');
fetch('https://public-api.expertfile.com/v2/organization/:corporation/staff/:username', {
method: 'PUT',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': `Bearer ${accessToken}`
},
body: data
})
.then(response => response.json())
.then(json => {
const { success, data, error } = json
if (success) {
const { username } = data
console.log('Updated username', username)
}
})
.catch(error => console.error(error));