function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
somasundaram s 7somasundaram s 7 

how to updated existing user record ?

HI Guys ,

I will try to updated the existing user record . Here is the my sample code ,
  HttpClient client = new HttpClient();
            string requestMessage = "{\"NewPassword\":\"sv0xHAuM\"}";


            HttpContent content = new StringContent(requestMessage, Encoding.UTF8, "application/json");
            //string requestMessage = "<root><name>DevForce21</name><accountnumber>8994432</accountnumber></root>";
            //HttpContent content = new StringContent(requestMessage, Encoding.UTF8, "application/xml");
            string uri = InstanceUrl + API_ENDPOINT + "sobjects/User/0057F000002uZLMQA2" + "?_HttpMethod=PATCH";

            //create request message associated with POST verb
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Put, uri);

            //add token to header
            request.Headers.Add("Authorization", "Bearer " + AuthToken);

            //return xml to the caller
            request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            request.Content = content;
            var response = client.SendAsync(request).Result;
            return response.Content.ReadAsStringAsync().Result;         
.I am getting the error "Method Not allowed ".

Kindly advice to fix this issue.
GauravGargGauravGarg

Hi Sonam,

Could you please check, if the Integration user has full access on Salesforce. 

Thanks,

Gaurav
Skype: gaurav62990

somasundaram s 7somasundaram s 7
hi ,
i have fixed .
i am facing the issue this line (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Put, uri);).

correct code :

(HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, uri);).

Thanks ,
Somu