Project

General

Profile

Need clarification on how to update or post data to redmine

Added by Thirumala Chary about 3 years ago

Hi Team,

We are trying to update and post the data to Redmine. We are getting 401(Authorization Required) error.
Please find below credentials which we are using.
UserName="ramsytesting",Password="ramsytesting"

We are using below type of code with to update and post data.

var httpClient = new HttpClient();
var username = "ramsytesting";
var response = new HttpResponseMessage();
var password = "ramsytesting";
var postData = "Data which we want to post to Redmine"

String authInfo = AuthProvider.BasicAuthProvider.UserName + ":" + AuthProvider.BasicAuthProvider.Password;
authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", authInfo);
var jsonContent = jsoninput;
var httpContent = new StringContent(jsonContent);
response = await client.PutAsync("http://ramsytesting.m.redmine.org/issues/40.json", httpContent).ConfigureAwait(false);