Create User Using C#

Hi,

I’m trying to follow the API I was able to create a user through CURL, but using C# code it gives an error and in Postman it returns

<ocs>
<meta>
<status>failure</status>
<statuscode>997</statuscode>
<message>Password confirmation is required</message>
<totalitems></totalitems>
<itemsperpage></itemsperpage>
</meta>
<data/>
</ocs>

I know when creating a user through the browser or some other activities, it asks to re-enter the admin password although I’m signed in with the admin user, but through postman or code, I send the admin username:password once, how can I confirm or any solution for this issue?
Thanks

This basically means that your session is too old to perform admin activity (30min timeout).
Make sure you:

  1. Use an app token instead of the real user password.
  2. Send the OCS-APIRequest: true header on each request

Can you show your code?

Thanks for the answer, the code is below, keep in mind that its C# code

string requestURL = "http://***************/ocs/v1.php/cloud/users?userid=" + userID+ "&password="+password;

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestURL);
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
request.Headers.Add("OCS-APIRequest", "true");
request.Headers.Add("Authorization", "Basic " + CommonTools.Base64Encode("admin:*****"));

WebResponse webResponse = request.GetResponse();