I'm trying to save a user profile field back to SharePoint using Javascript running within the portal. The request is kicking back a 400 error with no real descriptions of what the error might be. From what I understand, in SharePoint Online, using these older web services is the only way to save profile fields back to a user from a page.
Below is the code running....
function SaveUserProperty(accountName, propertyName, propertyValue) {
writeResult("Setting User Property for " + accountName);
// this variable contains the XML that is passed to the SOAP web service
// about which account will have which property modified
var newData = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3. xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ModifyUserPropertyByAccountName xmlns="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService"><accountName>' + accountName + '</accountName><newData><PropertyData><IsPrivacyChanged>false</IsPrivacyChanged><IsValueChanged>true</IsValueChanged><Name>' + propertyName + '</Name><Privacy>Public</Privacy><Values><ValueData><Value xsi:type="xsd:string">' + propertyValue + '</Value></ValueData></Values></PropertyData></newData></ModifyUserPropertyByAccountName></soap:Body></soap:Envelope>'
// this is the actual call to the web service and method responsible
// for modifying user profile property
$.ajax({
url: '/_vti_bin/UserProfileService.asmx',
beforeSend: function(xhr) {
xhr.setRequestHeader("SOAPAction", "http://microsoft.com/webservices/SharePointPortalServer/UserProfileService/ModifyUserPropertyByAccountName");
},
type: "POST",
dataType: "xml",
data: newData,
complete: completeSave,
contentType: "text/xml; charset=\"utf-8\""
});
return false;
}